// $ANTLR 3.1.1 src/astudy/parser/sql/QTemplate.g 2009-01-06 15:21:28

package astudy.parser.sql;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

import org.antlr.runtime.tree.*;

public class QTemplateParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "AS", "ORDER", "BY", "ASC", "DESC", "FETCH", "FIRST", "FROM", "ROW", "ROWS", "ONLY", "FOR", "UPDATE", "OF", "READ", "OPTIMIZE", "ALL", "WITH", "NC", "UR", "CS", "KEEP", "LOCKS", "RS", "RR", "SELECT", "UNION", "DISTINCT", "TABLE", "WHERE", "GROUP", "HAVING", "CROSS", "JOIN", "INNER", "LEFT", "RIGHT", "OUTER", "EXCEPTION", "ON", "NOT", "AND", "OR", "SOME", "ANY", "BETWEEN", "EXISTS", "IN", "LIKE", "ESCAPE", "IS", "NULL", "CONCAT", "CASE", "WHEN", "THEN", "ELSE", "END", "CAST", "StartNode", "QueryNode", "SubQueryNode", "NameNode", "AliasNode", "OrdersNode", "OrderNode", "SelectNode", "ColumnsNode", "ColumnNode", "TablesNode", "TableNode", "TableFunctionNode", "PaginationNode", "GroupByNode", "HavingNode", "ConditionsNode", "ExpressionsNode", "ExpressionNode", "CrossJoinNode", "InnerJoinNode", "ExceptionJoinNode", "LeftExceptionJoinNode", "RightExceptionJoinNode", "JoinNode", "LeftJoinNode", "RightJoinNode", "ExistsNode", "FunctionNode", "ArrayNode", "CompareNode", "NotNullNode", "CastNode", "CaseExpressionNode", "CaseNode", "COMMA", "DOUBLE_STAR", "STAR", "SEMICOLON", "LPAREN", "RPAREN", "EQ", "NE", "LE", "GT", "NL", "NG", "PLUS", "MINUS", "DOUBLE_BITWISEOR", "DIVIDE", "DIGIT", "INTEGER", "DECIMAL", "FLOAT_POINT", "CHARACTER_STRING", "TABLE_COLUMNS", "IDENTIFIER", "WHITESPACE", "SINGLELINE_COMMENT", "MULTILINE_COMMENT", "'GRAPHIC_STRING'", "'BINARY-STRING'", "'DECIMAL_POINT'", "'Delimiters'", "'current date'"
    };
    public static final int COMMA=98;
    public static final int EXISTS=50;
    public static final int ExceptionJoinNode=84;
    public static final int FETCH=9;
    public static final int MINUS=111;
    public static final int AS=4;
    public static final int END=61;
    public static final int THEN=59;
    public static final int OrdersNode=68;
    public static final int ColumnNode=72;
    public static final int ON=43;
    public static final int ORDER=5;
    public static final int AND=45;
    public static final int T__128=128;
    public static final int LOCKS=26;
    public static final int RIGHT=40;
    public static final int CONCAT=56;
    public static final int SELECT=29;
    public static final int LE=106;
    public static final int NG=109;
    public static final int RPAREN=103;
    public static final int BETWEEN=49;
    public static final int DESC=8;
    public static final int CaseExpressionNode=96;
    public static final int PLUS=110;
    public static final int UNION=30;
    public static final int DISTINCT=31;
    public static final int WHEN=58;
    public static final int CompareNode=93;
    public static final int EQ=104;
    public static final int LeftExceptionJoinNode=85;
    public static final int UR=23;
    public static final int OF=17;
    public static final int UPDATE=16;
    public static final int ArrayNode=92;
    public static final int OPTIMIZE=19;
    public static final int PaginationNode=76;
    public static final int ANY=48;
    public static final int CASE=57;
    public static final int FLOAT_POINT=117;
    public static final int TABLE=32;
    public static final int ELSE=60;
    public static final int T__125=125;
    public static final int SEMICOLON=101;
    public static final int CS=24;
    public static final int CrossJoinNode=82;
    public static final int NotNullNode=94;
    public static final int FIRST=10;
    public static final int NULL=55;
    public static final int KEEP=25;
    public static final int ExpressionNode=81;
    public static final int HAVING=35;
    public static final int IDENTIFIER=120;
    public static final int ALL=20;
    public static final int T__124=124;
    public static final int JoinNode=87;
    public static final int CHARACTER_STRING=118;
    public static final int HavingNode=78;
    public static final int WHERE=33;
    public static final int SubQueryNode=65;
    public static final int DOUBLE_BITWISEOR=112;
    public static final int LeftJoinNode=88;
    public static final int T__126=126;
    public static final int CAST=62;
    public static final int INNER=38;
    public static final int FunctionNode=91;
    public static final int ROWS=13;
    public static final int TABLE_COLUMNS=119;
    public static final int DECIMAL=116;
    public static final int DOUBLE_STAR=99;
    public static final int OR=46;
    public static final int NameNode=66;
    public static final int TablesNode=73;
    public static final int INTEGER=115;
    public static final int DIVIDE=113;
    public static final int ColumnsNode=71;
    public static final int NL=108;
    public static final int BY=6;
    public static final int RR=28;
    public static final int GROUP=34;
    public static final int T__127=127;
    public static final int ESCAPE=53;
    public static final int QueryNode=64;
    public static final int LPAREN=102;
    public static final int SINGLELINE_COMMENT=122;
    public static final int DIGIT=114;
    public static final int LEFT=39;
    public static final int StartNode=63;
    public static final int ConditionsNode=79;
    public static final int JOIN=37;
    public static final int OUTER=41;
    public static final int SelectNode=70;
    public static final int FROM=11;
    public static final int NC=22;
    public static final int ExistsNode=90;
    public static final int TableFunctionNode=75;
    public static final int InnerJoinNode=83;
    public static final int RightExceptionJoinNode=86;
    public static final int RS=27;
    public static final int IS=54;
    public static final int ONLY=14;
    public static final int MULTILINE_COMMENT=123;
    public static final int GT=107;
    public static final int NE=105;
    public static final int CastNode=95;
    public static final int ASC=7;
    public static final int TableNode=74;
    public static final int GroupByNode=77;
    public static final int ExpressionsNode=80;
    public static final int LIKE=52;
    public static final int RightJoinNode=89;
    public static final int WHITESPACE=121;
    public static final int WITH=21;
    public static final int IN=51;
    public static final int SOME=47;
    public static final int OrderNode=69;
    public static final int EOF=-1;
    public static final int CROSS=36;
    public static final int FOR=15;
    public static final int STAR=100;
    public static final int NOT=44;
    public static final int AliasNode=67;
    public static final int CaseNode=97;
    public static final int READ=18;
    public static final int ROW=12;
    public static final int EXCEPTION=42;

    // delegates
    // delegators


        public QTemplateParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public QTemplateParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return QTemplateParser.tokenNames; }
    public String getGrammarFileName() { return "src/astudy/parser/sql/QTemplate.g"; }


    public static class start_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "start"
    // src/astudy/parser/sql/QTemplate.g:173:1: start : ss+= selectStatement ( SEMICOLON ss+= selectStatement )* ( SEMICOLON )? EOF -> ^( StartNode ( $ss)* ) ;
    public final QTemplateParser.start_return start() throws RecognitionException {
        QTemplateParser.start_return retval = new QTemplateParser.start_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token SEMICOLON1=null;
        Token SEMICOLON2=null;
        Token EOF3=null;
        List list_ss=null;
        RuleReturnScope ss = null;
        Object SEMICOLON1_tree=null;
        Object SEMICOLON2_tree=null;
        Object EOF3_tree=null;
        RewriteRuleTokenStream stream_SEMICOLON=new RewriteRuleTokenStream(adaptor,"token SEMICOLON");
        RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF");
        RewriteRuleSubtreeStream stream_selectStatement=new RewriteRuleSubtreeStream(adaptor,"rule selectStatement");
        try {
            // src/astudy/parser/sql/QTemplate.g:174:2: (ss+= selectStatement ( SEMICOLON ss+= selectStatement )* ( SEMICOLON )? EOF -> ^( StartNode ( $ss)* ) )
            // src/astudy/parser/sql/QTemplate.g:174:5: ss+= selectStatement ( SEMICOLON ss+= selectStatement )* ( SEMICOLON )? EOF
            {
            pushFollow(FOLLOW_selectStatement_in_start1118);
            ss=selectStatement();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_selectStatement.add(ss.getTree());
            if (list_ss==null) list_ss=new ArrayList();
            list_ss.add(ss.getTree());

            // src/astudy/parser/sql/QTemplate.g:174:25: ( SEMICOLON ss+= selectStatement )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==SEMICOLON) ) {
                    int LA1_1 = input.LA(2);

                    if ( (LA1_1==WITH||LA1_1==SELECT||LA1_1==LPAREN) ) {
                        alt1=1;
                    }


                }


                switch (alt1) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:174:26: SEMICOLON ss+= selectStatement
            	    {
            	    SEMICOLON1=(Token)match(input,SEMICOLON,FOLLOW_SEMICOLON_in_start1121); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_SEMICOLON.add(SEMICOLON1);

            	    pushFollow(FOLLOW_selectStatement_in_start1125);
            	    ss=selectStatement();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_selectStatement.add(ss.getTree());
            	    if (list_ss==null) list_ss=new ArrayList();
            	    list_ss.add(ss.getTree());


            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);

            // src/astudy/parser/sql/QTemplate.g:174:58: ( SEMICOLON )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==SEMICOLON) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:174:59: SEMICOLON
                    {
                    SEMICOLON2=(Token)match(input,SEMICOLON,FOLLOW_SEMICOLON_in_start1130); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_SEMICOLON.add(SEMICOLON2);


                    }
                    break;

            }

            EOF3=(Token)match(input,EOF,FOLLOW_EOF_in_start1136); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_EOF.add(EOF3);



            // AST REWRITE
            // elements: ss
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: ss
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_ss=new RewriteRuleSubtreeStream(adaptor,"token ss",list_ss);
            root_0 = (Object)adaptor.nil();
            // 176:3: -> ^( StartNode ( $ss)* )
            {
                // src/astudy/parser/sql/QTemplate.g:176:6: ^( StartNode ( $ss)* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(StartNode, "StartNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:176:18: ( $ss)*
                while ( stream_ss.hasNext() ) {
                    adaptor.addChild(root_1, stream_ss.nextTree());

                }
                stream_ss.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "start"

    public static class selectStatement_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "selectStatement"
    // src/astudy/parser/sql/QTemplate.g:179:1: selectStatement : ( WITH commonTableExpression ( COMMA commonTableExpression )* )? fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause | readOnlyClause | optimizeClause | isolationClause )* -> ^( QueryNode ( commonTableExpression )* fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause )* ( readOnlyClause )* ( optimizeClause )* ( isolationClause )* ) ;
    public final QTemplateParser.selectStatement_return selectStatement() throws RecognitionException {
        QTemplateParser.selectStatement_return retval = new QTemplateParser.selectStatement_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token WITH4=null;
        Token COMMA6=null;
        QTemplateParser.commonTableExpression_return commonTableExpression5 = null;

        QTemplateParser.commonTableExpression_return commonTableExpression7 = null;

        QTemplateParser.fullselect_return fullselect8 = null;

        QTemplateParser.orderByClause_return orderByClause9 = null;

        QTemplateParser.fetchFirstClause_return fetchFirstClause10 = null;

        QTemplateParser.updateClause_return updateClause11 = null;

        QTemplateParser.readOnlyClause_return readOnlyClause12 = null;

        QTemplateParser.optimizeClause_return optimizeClause13 = null;

        QTemplateParser.isolationClause_return isolationClause14 = null;


        Object WITH4_tree=null;
        Object COMMA6_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_WITH=new RewriteRuleTokenStream(adaptor,"token WITH");
        RewriteRuleSubtreeStream stream_optimizeClause=new RewriteRuleSubtreeStream(adaptor,"rule optimizeClause");
        RewriteRuleSubtreeStream stream_commonTableExpression=new RewriteRuleSubtreeStream(adaptor,"rule commonTableExpression");
        RewriteRuleSubtreeStream stream_updateClause=new RewriteRuleSubtreeStream(adaptor,"rule updateClause");
        RewriteRuleSubtreeStream stream_isolationClause=new RewriteRuleSubtreeStream(adaptor,"rule isolationClause");
        RewriteRuleSubtreeStream stream_readOnlyClause=new RewriteRuleSubtreeStream(adaptor,"rule readOnlyClause");
        RewriteRuleSubtreeStream stream_fullselect=new RewriteRuleSubtreeStream(adaptor,"rule fullselect");
        RewriteRuleSubtreeStream stream_orderByClause=new RewriteRuleSubtreeStream(adaptor,"rule orderByClause");
        RewriteRuleSubtreeStream stream_fetchFirstClause=new RewriteRuleSubtreeStream(adaptor,"rule fetchFirstClause");
        try {
            // src/astudy/parser/sql/QTemplate.g:180:2: ( ( WITH commonTableExpression ( COMMA commonTableExpression )* )? fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause | readOnlyClause | optimizeClause | isolationClause )* -> ^( QueryNode ( commonTableExpression )* fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause )* ( readOnlyClause )* ( optimizeClause )* ( isolationClause )* ) )
            // src/astudy/parser/sql/QTemplate.g:181:6: ( WITH commonTableExpression ( COMMA commonTableExpression )* )? fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause | readOnlyClause | optimizeClause | isolationClause )*
            {
            // src/astudy/parser/sql/QTemplate.g:181:6: ( WITH commonTableExpression ( COMMA commonTableExpression )* )?
            int alt4=2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0==WITH) ) {
                alt4=1;
            }
            switch (alt4) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:181:7: WITH commonTableExpression ( COMMA commonTableExpression )*
                    {
                    WITH4=(Token)match(input,WITH,FOLLOW_WITH_in_selectStatement1167); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_WITH.add(WITH4);

                    pushFollow(FOLLOW_commonTableExpression_in_selectStatement1169);
                    commonTableExpression5=commonTableExpression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_commonTableExpression.add(commonTableExpression5.getTree());
                    // src/astudy/parser/sql/QTemplate.g:181:34: ( COMMA commonTableExpression )*
                    loop3:
                    do {
                        int alt3=2;
                        int LA3_0 = input.LA(1);

                        if ( (LA3_0==COMMA) ) {
                            alt3=1;
                        }


                        switch (alt3) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:181:35: COMMA commonTableExpression
                    	    {
                    	    COMMA6=(Token)match(input,COMMA,FOLLOW_COMMA_in_selectStatement1172); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA6);

                    	    pushFollow(FOLLOW_commonTableExpression_in_selectStatement1174);
                    	    commonTableExpression7=commonTableExpression();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_commonTableExpression.add(commonTableExpression7.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop3;
                        }
                    } while (true);


                    }
                    break;

            }

            pushFollow(FOLLOW_fullselect_in_selectStatement1187);
            fullselect8=fullselect();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_fullselect.add(fullselect8.getTree());
            // src/astudy/parser/sql/QTemplate.g:183:6: ( orderByClause )?
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==ORDER) ) {
                alt5=1;
            }
            switch (alt5) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:183:7: orderByClause
                    {
                    pushFollow(FOLLOW_orderByClause_in_selectStatement1195);
                    orderByClause9=orderByClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_orderByClause.add(orderByClause9.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:184:6: ( fetchFirstClause )?
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0==FETCH) ) {
                alt6=1;
            }
            switch (alt6) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:184:7: fetchFirstClause
                    {
                    pushFollow(FOLLOW_fetchFirstClause_in_selectStatement1205);
                    fetchFirstClause10=fetchFirstClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_fetchFirstClause.add(fetchFirstClause10.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:185:6: ( updateClause | readOnlyClause | optimizeClause | isolationClause )*
            loop7:
            do {
                int alt7=5;
                switch ( input.LA(1) ) {
                case FOR:
                    {
                    int LA7_3 = input.LA(2);

                    if ( (LA7_3==UPDATE) ) {
                        alt7=1;
                    }
                    else if ( (LA7_3==READ) ) {
                        alt7=2;
                    }


                    }
                    break;
                case OPTIMIZE:
                    {
                    alt7=3;
                    }
                    break;
                case WITH:
                    {
                    alt7=4;
                    }
                    break;

                }

                switch (alt7) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:185:7: updateClause
            	    {
            	    pushFollow(FOLLOW_updateClause_in_selectStatement1215);
            	    updateClause11=updateClause();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_updateClause.add(updateClause11.getTree());

            	    }
            	    break;
            	case 2 :
            	    // src/astudy/parser/sql/QTemplate.g:185:22: readOnlyClause
            	    {
            	    pushFollow(FOLLOW_readOnlyClause_in_selectStatement1219);
            	    readOnlyClause12=readOnlyClause();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_readOnlyClause.add(readOnlyClause12.getTree());

            	    }
            	    break;
            	case 3 :
            	    // src/astudy/parser/sql/QTemplate.g:185:39: optimizeClause
            	    {
            	    pushFollow(FOLLOW_optimizeClause_in_selectStatement1223);
            	    optimizeClause13=optimizeClause();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_optimizeClause.add(optimizeClause13.getTree());

            	    }
            	    break;
            	case 4 :
            	    // src/astudy/parser/sql/QTemplate.g:185:56: isolationClause
            	    {
            	    pushFollow(FOLLOW_isolationClause_in_selectStatement1227);
            	    isolationClause14=isolationClause();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_isolationClause.add(isolationClause14.getTree());

            	    }
            	    break;

            	default :
            	    break loop7;
                }
            } while (true);



            // AST REWRITE
            // elements: orderByClause, optimizeClause, fullselect, commonTableExpression, isolationClause, updateClause, readOnlyClause, fetchFirstClause
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 187:6: -> ^( QueryNode ( commonTableExpression )* fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause )* ( readOnlyClause )* ( optimizeClause )* ( isolationClause )* )
            {
                // src/astudy/parser/sql/QTemplate.g:187:9: ^( QueryNode ( commonTableExpression )* fullselect ( orderByClause )? ( fetchFirstClause )? ( updateClause )* ( readOnlyClause )* ( optimizeClause )* ( isolationClause )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(QueryNode, "QueryNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:188:8: ( commonTableExpression )*
                while ( stream_commonTableExpression.hasNext() ) {
                    adaptor.addChild(root_1, stream_commonTableExpression.nextTree());

                }
                stream_commonTableExpression.reset();
                adaptor.addChild(root_1, stream_fullselect.nextTree());
                // src/astudy/parser/sql/QTemplate.g:189:16: ( orderByClause )?
                if ( stream_orderByClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_orderByClause.nextTree());

                }
                stream_orderByClause.reset();
                // src/astudy/parser/sql/QTemplate.g:189:31: ( fetchFirstClause )?
                if ( stream_fetchFirstClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_fetchFirstClause.nextTree());

                }
                stream_fetchFirstClause.reset();
                // src/astudy/parser/sql/QTemplate.g:190:5: ( updateClause )*
                while ( stream_updateClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_updateClause.nextTree());

                }
                stream_updateClause.reset();
                // src/astudy/parser/sql/QTemplate.g:190:19: ( readOnlyClause )*
                while ( stream_readOnlyClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_readOnlyClause.nextTree());

                }
                stream_readOnlyClause.reset();
                // src/astudy/parser/sql/QTemplate.g:190:35: ( optimizeClause )*
                while ( stream_optimizeClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_optimizeClause.nextTree());

                }
                stream_optimizeClause.reset();
                // src/astudy/parser/sql/QTemplate.g:190:51: ( isolationClause )*
                while ( stream_isolationClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_isolationClause.nextTree());

                }
                stream_isolationClause.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "selectStatement"

    public static class commonTableExpression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "commonTableExpression"
    // src/astudy/parser/sql/QTemplate.g:194:1: commonTableExpression : ( STAR | refid= identifier ) ( LPAREN columnName ( COMMA columnName )* RPAREN )? AS LPAREN fullselect ( orderByClause )? ( fetchFirstClause )? RPAREN -> ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? ) ;
    public final QTemplateParser.commonTableExpression_return commonTableExpression() throws RecognitionException {
        QTemplateParser.commonTableExpression_return retval = new QTemplateParser.commonTableExpression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token STAR15=null;
        Token LPAREN16=null;
        Token COMMA18=null;
        Token RPAREN20=null;
        Token AS21=null;
        Token LPAREN22=null;
        Token RPAREN26=null;
        QTemplateParser.identifier_return refid = null;

        QTemplateParser.columnName_return columnName17 = null;

        QTemplateParser.columnName_return columnName19 = null;

        QTemplateParser.fullselect_return fullselect23 = null;

        QTemplateParser.orderByClause_return orderByClause24 = null;

        QTemplateParser.fetchFirstClause_return fetchFirstClause25 = null;


        Object STAR15_tree=null;
        Object LPAREN16_tree=null;
        Object COMMA18_tree=null;
        Object RPAREN20_tree=null;
        Object AS21_tree=null;
        Object LPAREN22_tree=null;
        Object RPAREN26_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_AS=new RewriteRuleTokenStream(adaptor,"token AS");
        RewriteRuleTokenStream stream_STAR=new RewriteRuleTokenStream(adaptor,"token STAR");
        RewriteRuleSubtreeStream stream_columnName=new RewriteRuleSubtreeStream(adaptor,"rule columnName");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        RewriteRuleSubtreeStream stream_fullselect=new RewriteRuleSubtreeStream(adaptor,"rule fullselect");
        RewriteRuleSubtreeStream stream_orderByClause=new RewriteRuleSubtreeStream(adaptor,"rule orderByClause");
        RewriteRuleSubtreeStream stream_fetchFirstClause=new RewriteRuleSubtreeStream(adaptor,"rule fetchFirstClause");
        try {
            // src/astudy/parser/sql/QTemplate.g:195:5: ( ( STAR | refid= identifier ) ( LPAREN columnName ( COMMA columnName )* RPAREN )? AS LPAREN fullselect ( orderByClause )? ( fetchFirstClause )? RPAREN -> ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? ) )
            // src/astudy/parser/sql/QTemplate.g:196:6: ( STAR | refid= identifier ) ( LPAREN columnName ( COMMA columnName )* RPAREN )? AS LPAREN fullselect ( orderByClause )? ( fetchFirstClause )? RPAREN
            {
            // src/astudy/parser/sql/QTemplate.g:196:6: ( STAR | refid= identifier )
            int alt8=2;
            int LA8_0 = input.LA(1);

            if ( (LA8_0==STAR) ) {
                alt8=1;
            }
            else if ( (LA8_0==IDENTIFIER) ) {
                alt8=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 8, 0, input);

                throw nvae;
            }
            switch (alt8) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:196:7: STAR
                    {
                    STAR15=(Token)match(input,STAR,FOLLOW_STAR_in_commonTableExpression1318); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_STAR.add(STAR15);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:196:14: refid= identifier
                    {
                    pushFollow(FOLLOW_identifier_in_commonTableExpression1324);
                    refid=identifier();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_identifier.add(refid.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:197:6: ( LPAREN columnName ( COMMA columnName )* RPAREN )?
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==LPAREN) ) {
                alt10=1;
            }
            switch (alt10) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:197:7: LPAREN columnName ( COMMA columnName )* RPAREN
                    {
                    LPAREN16=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_commonTableExpression1336); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN16);

                    pushFollow(FOLLOW_columnName_in_commonTableExpression1338);
                    columnName17=columnName();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_columnName.add(columnName17.getTree());
                    // src/astudy/parser/sql/QTemplate.g:197:25: ( COMMA columnName )*
                    loop9:
                    do {
                        int alt9=2;
                        int LA9_0 = input.LA(1);

                        if ( (LA9_0==COMMA) ) {
                            alt9=1;
                        }


                        switch (alt9) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:197:26: COMMA columnName
                    	    {
                    	    COMMA18=(Token)match(input,COMMA,FOLLOW_COMMA_in_commonTableExpression1341); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA18);

                    	    pushFollow(FOLLOW_columnName_in_commonTableExpression1343);
                    	    columnName19=columnName();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_columnName.add(columnName19.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop9;
                        }
                    } while (true);

                    RPAREN20=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_commonTableExpression1347); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN20);


                    }
                    break;

            }

            AS21=(Token)match(input,AS,FOLLOW_AS_in_commonTableExpression1356); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_AS.add(AS21);

            LPAREN22=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_commonTableExpression1358); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN22);

            pushFollow(FOLLOW_fullselect_in_commonTableExpression1367);
            fullselect23=fullselect();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_fullselect.add(fullselect23.getTree());
            // src/astudy/parser/sql/QTemplate.g:200:7: ( orderByClause )?
            int alt11=2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0==ORDER) ) {
                alt11=1;
            }
            switch (alt11) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:200:8: orderByClause
                    {
                    pushFollow(FOLLOW_orderByClause_in_commonTableExpression1377);
                    orderByClause24=orderByClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_orderByClause.add(orderByClause24.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:201:7: ( fetchFirstClause )?
            int alt12=2;
            int LA12_0 = input.LA(1);

            if ( (LA12_0==FETCH) ) {
                alt12=1;
            }
            switch (alt12) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:201:8: fetchFirstClause
                    {
                    pushFollow(FOLLOW_fetchFirstClause_in_commonTableExpression1389);
                    fetchFirstClause25=fetchFirstClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_fetchFirstClause.add(fetchFirstClause25.getTree());

                    }
                    break;

            }

            RPAREN26=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_commonTableExpression1399); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN26);



            // AST REWRITE
            // elements: fullselect, refid, fetchFirstClause, orderByClause
            // token labels: 
            // rule labels: retval, refid
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_refid=new RewriteRuleSubtreeStream(adaptor,"token refid",refid!=null?refid.tree:null);

            root_0 = (Object)adaptor.nil();
            // 204:6: -> ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? )
            {
                // src/astudy/parser/sql/QTemplate.g:204:9: ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(SubQueryNode, "SubQueryNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:205:8: ^( NameNode $refid)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_2);

                adaptor.addChild(root_2, stream_refid.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                adaptor.addChild(root_1, stream_fullselect.nextTree());
                // src/astudy/parser/sql/QTemplate.g:207:8: ( orderByClause )?
                if ( stream_orderByClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_orderByClause.nextTree());

                }
                stream_orderByClause.reset();
                // src/astudy/parser/sql/QTemplate.g:208:8: ( fetchFirstClause )?
                if ( stream_fetchFirstClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_fetchFirstClause.nextTree());

                }
                stream_fetchFirstClause.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "commonTableExpression"

    public static class identifier_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "identifier"
    // src/astudy/parser/sql/QTemplate.g:212:1: identifier : IDENTIFIER ;
    public final QTemplateParser.identifier_return identifier() throws RecognitionException {
        QTemplateParser.identifier_return retval = new QTemplateParser.identifier_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token IDENTIFIER27=null;

        Object IDENTIFIER27_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:222:2: ( IDENTIFIER )
            // src/astudy/parser/sql/QTemplate.g:222:4: IDENTIFIER
            {
            root_0 = (Object)adaptor.nil();

            IDENTIFIER27=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_identifier1484); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            IDENTIFIER27_tree = (Object)adaptor.create(IDENTIFIER27);
            adaptor.addChild(root_0, IDENTIFIER27_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "identifier"

    public static class columnName_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "columnName"
    // src/astudy/parser/sql/QTemplate.g:225:1: columnName : IDENTIFIER ;
    public final QTemplateParser.columnName_return columnName() throws RecognitionException {
        QTemplateParser.columnName_return retval = new QTemplateParser.columnName_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token IDENTIFIER28=null;

        Object IDENTIFIER28_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:226:2: ( IDENTIFIER )
            // src/astudy/parser/sql/QTemplate.g:226:4: IDENTIFIER
            {
            root_0 = (Object)adaptor.nil();

            IDENTIFIER28=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_columnName1496); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            IDENTIFIER28_tree = (Object)adaptor.create(IDENTIFIER28);
            adaptor.addChild(root_0, IDENTIFIER28_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "columnName"

    public static class fullselect_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "fullselect"
    // src/astudy/parser/sql/QTemplate.g:229:1: fullselect : subQueryExpression ( UNION ( DISTINCT | ALL )? subQueryExpression )* -> ( subQueryExpression )+ ;
    public final QTemplateParser.fullselect_return fullselect() throws RecognitionException {
        QTemplateParser.fullselect_return retval = new QTemplateParser.fullselect_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token UNION30=null;
        Token DISTINCT31=null;
        Token ALL32=null;
        QTemplateParser.subQueryExpression_return subQueryExpression29 = null;

        QTemplateParser.subQueryExpression_return subQueryExpression33 = null;


        Object UNION30_tree=null;
        Object DISTINCT31_tree=null;
        Object ALL32_tree=null;
        RewriteRuleTokenStream stream_UNION=new RewriteRuleTokenStream(adaptor,"token UNION");
        RewriteRuleTokenStream stream_DISTINCT=new RewriteRuleTokenStream(adaptor,"token DISTINCT");
        RewriteRuleTokenStream stream_ALL=new RewriteRuleTokenStream(adaptor,"token ALL");
        RewriteRuleSubtreeStream stream_subQueryExpression=new RewriteRuleSubtreeStream(adaptor,"rule subQueryExpression");
        try {
            // src/astudy/parser/sql/QTemplate.g:230:2: ( subQueryExpression ( UNION ( DISTINCT | ALL )? subQueryExpression )* -> ( subQueryExpression )+ )
            // src/astudy/parser/sql/QTemplate.g:230:4: subQueryExpression ( UNION ( DISTINCT | ALL )? subQueryExpression )*
            {
            pushFollow(FOLLOW_subQueryExpression_in_fullselect1509);
            subQueryExpression29=subQueryExpression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_subQueryExpression.add(subQueryExpression29.getTree());
            // src/astudy/parser/sql/QTemplate.g:231:3: ( UNION ( DISTINCT | ALL )? subQueryExpression )*
            loop14:
            do {
                int alt14=2;
                alt14 = dfa14.predict(input);
                switch (alt14) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:231:5: UNION ( DISTINCT | ALL )? subQueryExpression
            	    {
            	    UNION30=(Token)match(input,UNION,FOLLOW_UNION_in_fullselect1515); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_UNION.add(UNION30);

            	    // src/astudy/parser/sql/QTemplate.g:231:11: ( DISTINCT | ALL )?
            	    int alt13=3;
            	    int LA13_0 = input.LA(1);

            	    if ( (LA13_0==DISTINCT) ) {
            	        alt13=1;
            	    }
            	    else if ( (LA13_0==ALL) ) {
            	        alt13=2;
            	    }
            	    switch (alt13) {
            	        case 1 :
            	            // src/astudy/parser/sql/QTemplate.g:231:12: DISTINCT
            	            {
            	            DISTINCT31=(Token)match(input,DISTINCT,FOLLOW_DISTINCT_in_fullselect1518); if (state.failed) return retval; 
            	            if ( state.backtracking==0 ) stream_DISTINCT.add(DISTINCT31);


            	            }
            	            break;
            	        case 2 :
            	            // src/astudy/parser/sql/QTemplate.g:231:23: ALL
            	            {
            	            ALL32=(Token)match(input,ALL,FOLLOW_ALL_in_fullselect1522); if (state.failed) return retval; 
            	            if ( state.backtracking==0 ) stream_ALL.add(ALL32);


            	            }
            	            break;

            	    }

            	    pushFollow(FOLLOW_subQueryExpression_in_fullselect1526);
            	    subQueryExpression33=subQueryExpression();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_subQueryExpression.add(subQueryExpression33.getTree());

            	    }
            	    break;

            	default :
            	    break loop14;
                }
            } while (true);



            // AST REWRITE
            // elements: subQueryExpression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 233:3: -> ( subQueryExpression )+
            {
                if ( !(stream_subQueryExpression.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_subQueryExpression.hasNext() ) {
                    adaptor.addChild(root_0, stream_subQueryExpression.nextTree());

                }
                stream_subQueryExpression.reset();

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "fullselect"

    public static class subQueryExpression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "subQueryExpression"
    // src/astudy/parser/sql/QTemplate.g:236:1: subQueryExpression : ( subselect -> subselect | LPAREN fullselect RPAREN -> fullselect );
    public final QTemplateParser.subQueryExpression_return subQueryExpression() throws RecognitionException {
        QTemplateParser.subQueryExpression_return retval = new QTemplateParser.subQueryExpression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LPAREN35=null;
        Token RPAREN37=null;
        QTemplateParser.subselect_return subselect34 = null;

        QTemplateParser.fullselect_return fullselect36 = null;


        Object LPAREN35_tree=null;
        Object RPAREN37_tree=null;
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleSubtreeStream stream_subselect=new RewriteRuleSubtreeStream(adaptor,"rule subselect");
        RewriteRuleSubtreeStream stream_fullselect=new RewriteRuleSubtreeStream(adaptor,"rule fullselect");
        try {
            // src/astudy/parser/sql/QTemplate.g:237:2: ( subselect -> subselect | LPAREN fullselect RPAREN -> fullselect )
            int alt15=2;
            int LA15_0 = input.LA(1);

            if ( (LA15_0==SELECT) ) {
                alt15=1;
            }
            else if ( (LA15_0==LPAREN) ) {
                alt15=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 15, 0, input);

                throw nvae;
            }
            switch (alt15) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:237:4: subselect
                    {
                    pushFollow(FOLLOW_subselect_in_subQueryExpression1551);
                    subselect34=subselect();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_subselect.add(subselect34.getTree());


                    // AST REWRITE
                    // elements: subselect
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 238:3: -> subselect
                    {
                        adaptor.addChild(root_0, stream_subselect.nextTree());

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:240:5: LPAREN fullselect RPAREN
                    {
                    LPAREN35=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_subQueryExpression1566); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN35);

                    pushFollow(FOLLOW_fullselect_in_subQueryExpression1568);
                    fullselect36=fullselect();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_fullselect.add(fullselect36.getTree());
                    RPAREN37=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_subQueryExpression1570); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN37);



                    // AST REWRITE
                    // elements: fullselect
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 241:3: -> fullselect
                    {
                        adaptor.addChild(root_0, stream_fullselect.nextTree());

                    }

                    retval.tree = root_0;}
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subQueryExpression"

    public static class subselect_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "subselect"
    // src/astudy/parser/sql/QTemplate.g:244:1: subselect : selectClause fromClause ( whereClause )? ( groupByClause )? ( havingClause )? -> ^( SelectNode fromClause selectClause ( whereClause )? ( groupByClause )? ( havingClause )? ) ;
    public final QTemplateParser.subselect_return subselect() throws RecognitionException {
        QTemplateParser.subselect_return retval = new QTemplateParser.subselect_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.selectClause_return selectClause38 = null;

        QTemplateParser.fromClause_return fromClause39 = null;

        QTemplateParser.whereClause_return whereClause40 = null;

        QTemplateParser.groupByClause_return groupByClause41 = null;

        QTemplateParser.havingClause_return havingClause42 = null;


        RewriteRuleSubtreeStream stream_selectClause=new RewriteRuleSubtreeStream(adaptor,"rule selectClause");
        RewriteRuleSubtreeStream stream_fromClause=new RewriteRuleSubtreeStream(adaptor,"rule fromClause");
        RewriteRuleSubtreeStream stream_havingClause=new RewriteRuleSubtreeStream(adaptor,"rule havingClause");
        RewriteRuleSubtreeStream stream_whereClause=new RewriteRuleSubtreeStream(adaptor,"rule whereClause");
        RewriteRuleSubtreeStream stream_groupByClause=new RewriteRuleSubtreeStream(adaptor,"rule groupByClause");
        try {
            // src/astudy/parser/sql/QTemplate.g:245:2: ( selectClause fromClause ( whereClause )? ( groupByClause )? ( havingClause )? -> ^( SelectNode fromClause selectClause ( whereClause )? ( groupByClause )? ( havingClause )? ) )
            // src/astudy/parser/sql/QTemplate.g:245:4: selectClause fromClause ( whereClause )? ( groupByClause )? ( havingClause )?
            {
            pushFollow(FOLLOW_selectClause_in_subselect1588);
            selectClause38=selectClause();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_selectClause.add(selectClause38.getTree());
            pushFollow(FOLLOW_fromClause_in_subselect1593);
            fromClause39=fromClause();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_fromClause.add(fromClause39.getTree());
            // src/astudy/parser/sql/QTemplate.g:247:3: ( whereClause )?
            int alt16=2;
            alt16 = dfa16.predict(input);
            switch (alt16) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:247:3: whereClause
                    {
                    pushFollow(FOLLOW_whereClause_in_subselect1598);
                    whereClause40=whereClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_whereClause.add(whereClause40.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:248:3: ( groupByClause )?
            int alt17=2;
            alt17 = dfa17.predict(input);
            switch (alt17) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:248:3: groupByClause
                    {
                    pushFollow(FOLLOW_groupByClause_in_subselect1604);
                    groupByClause41=groupByClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_groupByClause.add(groupByClause41.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:249:3: ( havingClause )?
            int alt18=2;
            alt18 = dfa18.predict(input);
            switch (alt18) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:249:3: havingClause
                    {
                    pushFollow(FOLLOW_havingClause_in_subselect1610);
                    havingClause42=havingClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_havingClause.add(havingClause42.getTree());

                    }
                    break;

            }



            // AST REWRITE
            // elements: havingClause, selectClause, groupByClause, whereClause, fromClause
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 251:3: -> ^( SelectNode fromClause selectClause ( whereClause )? ( groupByClause )? ( havingClause )? )
            {
                // src/astudy/parser/sql/QTemplate.g:251:6: ^( SelectNode fromClause selectClause ( whereClause )? ( groupByClause )? ( havingClause )? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(SelectNode, "SelectNode"), root_1);

                adaptor.addChild(root_1, stream_fromClause.nextTree());
                adaptor.addChild(root_1, stream_selectClause.nextTree());
                // src/astudy/parser/sql/QTemplate.g:254:5: ( whereClause )?
                if ( stream_whereClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_whereClause.nextTree());

                }
                stream_whereClause.reset();
                // src/astudy/parser/sql/QTemplate.g:255:5: ( groupByClause )?
                if ( stream_groupByClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_groupByClause.nextTree());

                }
                stream_groupByClause.reset();
                // src/astudy/parser/sql/QTemplate.g:256:5: ( havingClause )?
                if ( stream_havingClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_havingClause.nextTree());

                }
                stream_havingClause.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subselect"

    public static class selectClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "selectClause"
    // src/astudy/parser/sql/QTemplate.g:260:1: selectClause : SELECT ( ALL | DISTINCT )? ( selectItem ( COMMA selectItem )* ) -> ^( ColumnsNode ( ^( ColumnNode selectItem ) )+ ) ;
    public final QTemplateParser.selectClause_return selectClause() throws RecognitionException {
        QTemplateParser.selectClause_return retval = new QTemplateParser.selectClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token SELECT43=null;
        Token ALL44=null;
        Token DISTINCT45=null;
        Token COMMA47=null;
        QTemplateParser.selectItem_return selectItem46 = null;

        QTemplateParser.selectItem_return selectItem48 = null;


        Object SELECT43_tree=null;
        Object ALL44_tree=null;
        Object DISTINCT45_tree=null;
        Object COMMA47_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_DISTINCT=new RewriteRuleTokenStream(adaptor,"token DISTINCT");
        RewriteRuleTokenStream stream_ALL=new RewriteRuleTokenStream(adaptor,"token ALL");
        RewriteRuleTokenStream stream_SELECT=new RewriteRuleTokenStream(adaptor,"token SELECT");
        RewriteRuleSubtreeStream stream_selectItem=new RewriteRuleSubtreeStream(adaptor,"rule selectItem");
        try {
            // src/astudy/parser/sql/QTemplate.g:261:2: ( SELECT ( ALL | DISTINCT )? ( selectItem ( COMMA selectItem )* ) -> ^( ColumnsNode ( ^( ColumnNode selectItem ) )+ ) )
            // src/astudy/parser/sql/QTemplate.g:261:4: SELECT ( ALL | DISTINCT )? ( selectItem ( COMMA selectItem )* )
            {
            SELECT43=(Token)match(input,SELECT,FOLLOW_SELECT_in_selectClause1680); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_SELECT.add(SELECT43);

            // src/astudy/parser/sql/QTemplate.g:261:11: ( ALL | DISTINCT )?
            int alt19=3;
            alt19 = dfa19.predict(input);
            switch (alt19) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:261:13: ALL
                    {
                    ALL44=(Token)match(input,ALL,FOLLOW_ALL_in_selectClause1684); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ALL.add(ALL44);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:261:19: DISTINCT
                    {
                    DISTINCT45=(Token)match(input,DISTINCT,FOLLOW_DISTINCT_in_selectClause1688); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_DISTINCT.add(DISTINCT45);


                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:262:3: ( selectItem ( COMMA selectItem )* )
            // src/astudy/parser/sql/QTemplate.g:262:4: selectItem ( COMMA selectItem )*
            {
            pushFollow(FOLLOW_selectItem_in_selectClause1696);
            selectItem46=selectItem();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_selectItem.add(selectItem46.getTree());
            // src/astudy/parser/sql/QTemplate.g:262:15: ( COMMA selectItem )*
            loop20:
            do {
                int alt20=2;
                int LA20_0 = input.LA(1);

                if ( (LA20_0==COMMA) ) {
                    alt20=1;
                }


                switch (alt20) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:262:16: COMMA selectItem
            	    {
            	    COMMA47=(Token)match(input,COMMA,FOLLOW_COMMA_in_selectClause1699); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA47);

            	    pushFollow(FOLLOW_selectItem_in_selectClause1701);
            	    selectItem48=selectItem();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_selectItem.add(selectItem48.getTree());

            	    }
            	    break;

            	default :
            	    break loop20;
                }
            } while (true);


            }



            // AST REWRITE
            // elements: selectItem
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 264:3: -> ^( ColumnsNode ( ^( ColumnNode selectItem ) )+ )
            {
                // src/astudy/parser/sql/QTemplate.g:264:6: ^( ColumnsNode ( ^( ColumnNode selectItem ) )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ColumnsNode, "ColumnsNode"), root_1);

                if ( !(stream_selectItem.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_selectItem.hasNext() ) {
                    // src/astudy/parser/sql/QTemplate.g:264:20: ^( ColumnNode selectItem )
                    {
                    Object root_2 = (Object)adaptor.nil();
                    root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ColumnNode, "ColumnNode"), root_2);

                    adaptor.addChild(root_2, stream_selectItem.nextTree());

                    adaptor.addChild(root_1, root_2);
                    }

                }
                stream_selectItem.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "selectClause"

    public static class selectItem_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "selectItem"
    // src/astudy/parser/sql/QTemplate.g:267:1: selectItem : ( STAR -> ^( NameNode STAR ) | TABLE_COLUMNS -> ^( NameNode TABLE_COLUMNS ) | expression ( ( AS )? columnName )? -> ^( NameNode expression ) ( ^( AliasNode columnName ) )? );
    public final QTemplateParser.selectItem_return selectItem() throws RecognitionException {
        QTemplateParser.selectItem_return retval = new QTemplateParser.selectItem_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token STAR49=null;
        Token TABLE_COLUMNS50=null;
        Token AS52=null;
        QTemplateParser.expression_return expression51 = null;

        QTemplateParser.columnName_return columnName53 = null;


        Object STAR49_tree=null;
        Object TABLE_COLUMNS50_tree=null;
        Object AS52_tree=null;
        RewriteRuleTokenStream stream_AS=new RewriteRuleTokenStream(adaptor,"token AS");
        RewriteRuleTokenStream stream_TABLE_COLUMNS=new RewriteRuleTokenStream(adaptor,"token TABLE_COLUMNS");
        RewriteRuleTokenStream stream_STAR=new RewriteRuleTokenStream(adaptor,"token STAR");
        RewriteRuleSubtreeStream stream_columnName=new RewriteRuleSubtreeStream(adaptor,"rule columnName");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:268:2: ( STAR -> ^( NameNode STAR ) | TABLE_COLUMNS -> ^( NameNode TABLE_COLUMNS ) | expression ( ( AS )? columnName )? -> ^( NameNode expression ) ( ^( AliasNode columnName ) )? )
            int alt23=3;
            alt23 = dfa23.predict(input);
            switch (alt23) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:268:4: STAR
                    {
                    STAR49=(Token)match(input,STAR,FOLLOW_STAR_in_selectItem1735); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_STAR.add(STAR49);



                    // AST REWRITE
                    // elements: STAR
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 269:3: -> ^( NameNode STAR )
                    {
                        // src/astudy/parser/sql/QTemplate.g:269:6: ^( NameNode STAR )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_1);

                        adaptor.addChild(root_1, stream_STAR.nextNode());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:270:5: TABLE_COLUMNS
                    {
                    TABLE_COLUMNS50=(Token)match(input,TABLE_COLUMNS,FOLLOW_TABLE_COLUMNS_in_selectItem1752); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_TABLE_COLUMNS.add(TABLE_COLUMNS50);



                    // AST REWRITE
                    // elements: TABLE_COLUMNS
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 271:3: -> ^( NameNode TABLE_COLUMNS )
                    {
                        // src/astudy/parser/sql/QTemplate.g:271:6: ^( NameNode TABLE_COLUMNS )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_1);

                        adaptor.addChild(root_1, stream_TABLE_COLUMNS.nextNode());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 3 :
                    // src/astudy/parser/sql/QTemplate.g:272:5: expression ( ( AS )? columnName )?
                    {
                    pushFollow(FOLLOW_expression_in_selectItem1770);
                    expression51=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expression.add(expression51.getTree());
                    // src/astudy/parser/sql/QTemplate.g:272:16: ( ( AS )? columnName )?
                    int alt22=2;
                    int LA22_0 = input.LA(1);

                    if ( (LA22_0==AS||LA22_0==IDENTIFIER) ) {
                        alt22=1;
                    }
                    switch (alt22) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:272:17: ( AS )? columnName
                            {
                            // src/astudy/parser/sql/QTemplate.g:272:17: ( AS )?
                            int alt21=2;
                            int LA21_0 = input.LA(1);

                            if ( (LA21_0==AS) ) {
                                alt21=1;
                            }
                            switch (alt21) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:272:17: AS
                                    {
                                    AS52=(Token)match(input,AS,FOLLOW_AS_in_selectItem1773); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_AS.add(AS52);


                                    }
                                    break;

                            }

                            pushFollow(FOLLOW_columnName_in_selectItem1776);
                            columnName53=columnName();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) stream_columnName.add(columnName53.getTree());

                            }
                            break;

                    }



                    // AST REWRITE
                    // elements: columnName, expression
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 273:3: -> ^( NameNode expression ) ( ^( AliasNode columnName ) )?
                    {
                        // src/astudy/parser/sql/QTemplate.g:273:6: ^( NameNode expression )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_1);

                        adaptor.addChild(root_1, stream_expression.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }
                        // src/astudy/parser/sql/QTemplate.g:273:29: ( ^( AliasNode columnName ) )?
                        if ( stream_columnName.hasNext() ) {
                            // src/astudy/parser/sql/QTemplate.g:273:29: ^( AliasNode columnName )
                            {
                            Object root_1 = (Object)adaptor.nil();
                            root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(AliasNode, "AliasNode"), root_1);

                            adaptor.addChild(root_1, stream_columnName.nextTree());

                            adaptor.addChild(root_0, root_1);
                            }

                        }
                        stream_columnName.reset();

                    }

                    retval.tree = root_0;}
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "selectItem"

    public static class expression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "expression"
    // src/astudy/parser/sql/QTemplate.g:276:1: expression : subExpression ( binaryOperator subExpression )* ;
    public final QTemplateParser.expression_return expression() throws RecognitionException {
        QTemplateParser.expression_return retval = new QTemplateParser.expression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.subExpression_return subExpression54 = null;

        QTemplateParser.binaryOperator_return binaryOperator55 = null;

        QTemplateParser.subExpression_return subExpression56 = null;



        try {
            // src/astudy/parser/sql/QTemplate.g:277:2: ( subExpression ( binaryOperator subExpression )* )
            // src/astudy/parser/sql/QTemplate.g:277:5: subExpression ( binaryOperator subExpression )*
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_subExpression_in_expression1808);
            subExpression54=subExpression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) adaptor.addChild(root_0, subExpression54.getTree());
            // src/astudy/parser/sql/QTemplate.g:277:20: ( binaryOperator subExpression )*
            loop24:
            do {
                int alt24=2;
                alt24 = dfa24.predict(input);
                switch (alt24) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:277:21: binaryOperator subExpression
            	    {
            	    pushFollow(FOLLOW_binaryOperator_in_expression1812);
            	    binaryOperator55=binaryOperator();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) adaptor.addChild(root_0, binaryOperator55.getTree());
            	    pushFollow(FOLLOW_subExpression_in_expression1814);
            	    subExpression56=subExpression();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) adaptor.addChild(root_0, subExpression56.getTree());

            	    }
            	    break;

            	default :
            	    break loop24;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expression"

    public static class subExpression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "subExpression"
    // src/astudy/parser/sql/QTemplate.g:280:1: subExpression : ( unaryOperator )? ( function | LPAREN ( scalarSubSelect | expression ) RPAREN | constant | columnName | specialRegister | castSpecification | caseExpression ) -> ( unaryOperator )? ( function )? ( scalarSubSelect )? ( expression )? ( constant )? ( columnName )? ( specialRegister )? ( castSpecification )? ( caseExpression )? ;
    public final QTemplateParser.subExpression_return subExpression() throws RecognitionException {
        QTemplateParser.subExpression_return retval = new QTemplateParser.subExpression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LPAREN59=null;
        Token RPAREN62=null;
        QTemplateParser.unaryOperator_return unaryOperator57 = null;

        QTemplateParser.function_return function58 = null;

        QTemplateParser.scalarSubSelect_return scalarSubSelect60 = null;

        QTemplateParser.expression_return expression61 = null;

        QTemplateParser.constant_return constant63 = null;

        QTemplateParser.columnName_return columnName64 = null;

        QTemplateParser.specialRegister_return specialRegister65 = null;

        QTemplateParser.castSpecification_return castSpecification66 = null;

        QTemplateParser.caseExpression_return caseExpression67 = null;


        Object LPAREN59_tree=null;
        Object RPAREN62_tree=null;
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleSubtreeStream stream_castSpecification=new RewriteRuleSubtreeStream(adaptor,"rule castSpecification");
        RewriteRuleSubtreeStream stream_unaryOperator=new RewriteRuleSubtreeStream(adaptor,"rule unaryOperator");
        RewriteRuleSubtreeStream stream_scalarSubSelect=new RewriteRuleSubtreeStream(adaptor,"rule scalarSubSelect");
        RewriteRuleSubtreeStream stream_specialRegister=new RewriteRuleSubtreeStream(adaptor,"rule specialRegister");
        RewriteRuleSubtreeStream stream_columnName=new RewriteRuleSubtreeStream(adaptor,"rule columnName");
        RewriteRuleSubtreeStream stream_function=new RewriteRuleSubtreeStream(adaptor,"rule function");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_caseExpression=new RewriteRuleSubtreeStream(adaptor,"rule caseExpression");
        RewriteRuleSubtreeStream stream_constant=new RewriteRuleSubtreeStream(adaptor,"rule constant");
        try {
            // src/astudy/parser/sql/QTemplate.g:281:2: ( ( unaryOperator )? ( function | LPAREN ( scalarSubSelect | expression ) RPAREN | constant | columnName | specialRegister | castSpecification | caseExpression ) -> ( unaryOperator )? ( function )? ( scalarSubSelect )? ( expression )? ( constant )? ( columnName )? ( specialRegister )? ( castSpecification )? ( caseExpression )? )
            // src/astudy/parser/sql/QTemplate.g:282:3: ( unaryOperator )? ( function | LPAREN ( scalarSubSelect | expression ) RPAREN | constant | columnName | specialRegister | castSpecification | caseExpression )
            {
            // src/astudy/parser/sql/QTemplate.g:282:3: ( unaryOperator )?
            int alt25=2;
            alt25 = dfa25.predict(input);
            switch (alt25) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:282:3: unaryOperator
                    {
                    pushFollow(FOLLOW_unaryOperator_in_subExpression1830);
                    unaryOperator57=unaryOperator();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_unaryOperator.add(unaryOperator57.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:283:3: ( function | LPAREN ( scalarSubSelect | expression ) RPAREN | constant | columnName | specialRegister | castSpecification | caseExpression )
            int alt27=7;
            alt27 = dfa27.predict(input);
            switch (alt27) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:284:4: function
                    {
                    pushFollow(FOLLOW_function_in_subExpression1840);
                    function58=function();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_function.add(function58.getTree());

                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:285:7: LPAREN ( scalarSubSelect | expression ) RPAREN
                    {
                    LPAREN59=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_subExpression1848); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN59);

                    // src/astudy/parser/sql/QTemplate.g:285:14: ( scalarSubSelect | expression )
                    int alt26=2;
                    alt26 = dfa26.predict(input);
                    switch (alt26) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:285:15: scalarSubSelect
                            {
                            pushFollow(FOLLOW_scalarSubSelect_in_subExpression1851);
                            scalarSubSelect60=scalarSubSelect();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) stream_scalarSubSelect.add(scalarSubSelect60.getTree());

                            }
                            break;
                        case 2 :
                            // src/astudy/parser/sql/QTemplate.g:285:33: expression
                            {
                            pushFollow(FOLLOW_expression_in_subExpression1855);
                            expression61=expression();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) stream_expression.add(expression61.getTree());

                            }
                            break;

                    }

                    RPAREN62=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_subExpression1858); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN62);


                    }
                    break;
                case 3 :
                    // src/astudy/parser/sql/QTemplate.g:286:7: constant
                    {
                    pushFollow(FOLLOW_constant_in_subExpression1866);
                    constant63=constant();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_constant.add(constant63.getTree());

                    }
                    break;
                case 4 :
                    // src/astudy/parser/sql/QTemplate.g:287:7: columnName
                    {
                    pushFollow(FOLLOW_columnName_in_subExpression1874);
                    columnName64=columnName();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_columnName.add(columnName64.getTree());

                    }
                    break;
                case 5 :
                    // src/astudy/parser/sql/QTemplate.g:289:7: specialRegister
                    {
                    pushFollow(FOLLOW_specialRegister_in_subExpression1883);
                    specialRegister65=specialRegister();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_specialRegister.add(specialRegister65.getTree());

                    }
                    break;
                case 6 :
                    // src/astudy/parser/sql/QTemplate.g:291:7: castSpecification
                    {
                    pushFollow(FOLLOW_castSpecification_in_subExpression1892);
                    castSpecification66=castSpecification();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_castSpecification.add(castSpecification66.getTree());

                    }
                    break;
                case 7 :
                    // src/astudy/parser/sql/QTemplate.g:292:7: caseExpression
                    {
                    pushFollow(FOLLOW_caseExpression_in_subExpression1900);
                    caseExpression67=caseExpression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_caseExpression.add(caseExpression67.getTree());

                    }
                    break;

            }



            // AST REWRITE
            // elements: caseExpression, expression, function, constant, columnName, specialRegister, unaryOperator, castSpecification, scalarSubSelect
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 294:4: -> ( unaryOperator )? ( function )? ( scalarSubSelect )? ( expression )? ( constant )? ( columnName )? ( specialRegister )? ( castSpecification )? ( caseExpression )?
            {
                // src/astudy/parser/sql/QTemplate.g:294:7: ( unaryOperator )?
                if ( stream_unaryOperator.hasNext() ) {
                    adaptor.addChild(root_0, stream_unaryOperator.nextTree());

                }
                stream_unaryOperator.reset();
                // src/astudy/parser/sql/QTemplate.g:295:5: ( function )?
                if ( stream_function.hasNext() ) {
                    adaptor.addChild(root_0, stream_function.nextTree());

                }
                stream_function.reset();
                // src/astudy/parser/sql/QTemplate.g:296:5: ( scalarSubSelect )?
                if ( stream_scalarSubSelect.hasNext() ) {
                    adaptor.addChild(root_0, stream_scalarSubSelect.nextTree());

                }
                stream_scalarSubSelect.reset();
                // src/astudy/parser/sql/QTemplate.g:297:5: ( expression )?
                if ( stream_expression.hasNext() ) {
                    adaptor.addChild(root_0, stream_expression.nextTree());

                }
                stream_expression.reset();
                // src/astudy/parser/sql/QTemplate.g:298:5: ( constant )?
                if ( stream_constant.hasNext() ) {
                    adaptor.addChild(root_0, stream_constant.nextTree());

                }
                stream_constant.reset();
                // src/astudy/parser/sql/QTemplate.g:299:5: ( columnName )?
                if ( stream_columnName.hasNext() ) {
                    adaptor.addChild(root_0, stream_columnName.nextTree());

                }
                stream_columnName.reset();
                // src/astudy/parser/sql/QTemplate.g:301:4: ( specialRegister )?
                if ( stream_specialRegister.hasNext() ) {
                    adaptor.addChild(root_0, stream_specialRegister.nextTree());

                }
                stream_specialRegister.reset();
                // src/astudy/parser/sql/QTemplate.g:303:4: ( castSpecification )?
                if ( stream_castSpecification.hasNext() ) {
                    adaptor.addChild(root_0, stream_castSpecification.nextTree());

                }
                stream_castSpecification.reset();
                // src/astudy/parser/sql/QTemplate.g:304:4: ( caseExpression )?
                if ( stream_caseExpression.hasNext() ) {
                    adaptor.addChild(root_0, stream_caseExpression.nextTree());

                }
                stream_caseExpression.reset();

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subExpression"

    public static class function_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "function"
    // src/astudy/parser/sql/QTemplate.g:307:1: function : functionName= identifier LPAREN ( STAR | ( ALL | DISTINCT )? ( expression ( COMMA expression )* ) )? RPAREN -> ^( FunctionNode ^( NameNode $functionName) ( ^( ArrayNode ( expression )* ) )? ) ;
    public final QTemplateParser.function_return function() throws RecognitionException {
        QTemplateParser.function_return retval = new QTemplateParser.function_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LPAREN68=null;
        Token STAR69=null;
        Token ALL70=null;
        Token DISTINCT71=null;
        Token COMMA73=null;
        Token RPAREN75=null;
        QTemplateParser.identifier_return functionName = null;

        QTemplateParser.expression_return expression72 = null;

        QTemplateParser.expression_return expression74 = null;


        Object LPAREN68_tree=null;
        Object STAR69_tree=null;
        Object ALL70_tree=null;
        Object DISTINCT71_tree=null;
        Object COMMA73_tree=null;
        Object RPAREN75_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_DISTINCT=new RewriteRuleTokenStream(adaptor,"token DISTINCT");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_STAR=new RewriteRuleTokenStream(adaptor,"token STAR");
        RewriteRuleTokenStream stream_ALL=new RewriteRuleTokenStream(adaptor,"token ALL");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:308:2: (functionName= identifier LPAREN ( STAR | ( ALL | DISTINCT )? ( expression ( COMMA expression )* ) )? RPAREN -> ^( FunctionNode ^( NameNode $functionName) ( ^( ArrayNode ( expression )* ) )? ) )
            // src/astudy/parser/sql/QTemplate.g:308:4: functionName= identifier LPAREN ( STAR | ( ALL | DISTINCT )? ( expression ( COMMA expression )* ) )? RPAREN
            {
            pushFollow(FOLLOW_identifier_in_function1986);
            functionName=identifier();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_identifier.add(functionName.getTree());
            LPAREN68=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_function1991); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN68);

            // src/astudy/parser/sql/QTemplate.g:310:4: ( STAR | ( ALL | DISTINCT )? ( expression ( COMMA expression )* ) )?
            int alt30=3;
            alt30 = dfa30.predict(input);
            switch (alt30) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:310:6: STAR
                    {
                    STAR69=(Token)match(input,STAR,FOLLOW_STAR_in_function1999); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_STAR.add(STAR69);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:310:13: ( ALL | DISTINCT )? ( expression ( COMMA expression )* )
                    {
                    // src/astudy/parser/sql/QTemplate.g:310:13: ( ALL | DISTINCT )?
                    int alt28=3;
                    alt28 = dfa28.predict(input);
                    switch (alt28) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:310:14: ALL
                            {
                            ALL70=(Token)match(input,ALL,FOLLOW_ALL_in_function2004); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_ALL.add(ALL70);


                            }
                            break;
                        case 2 :
                            // src/astudy/parser/sql/QTemplate.g:310:18: DISTINCT
                            {
                            DISTINCT71=(Token)match(input,DISTINCT,FOLLOW_DISTINCT_in_function2006); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_DISTINCT.add(DISTINCT71);


                            }
                            break;

                    }

                    // src/astudy/parser/sql/QTemplate.g:310:29: ( expression ( COMMA expression )* )
                    // src/astudy/parser/sql/QTemplate.g:310:30: expression ( COMMA expression )*
                    {
                    pushFollow(FOLLOW_expression_in_function2011);
                    expression72=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expression.add(expression72.getTree());
                    // src/astudy/parser/sql/QTemplate.g:310:41: ( COMMA expression )*
                    loop29:
                    do {
                        int alt29=2;
                        int LA29_0 = input.LA(1);

                        if ( (LA29_0==COMMA) ) {
                            alt29=1;
                        }


                        switch (alt29) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:310:42: COMMA expression
                    	    {
                    	    COMMA73=(Token)match(input,COMMA,FOLLOW_COMMA_in_function2014); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA73);

                    	    pushFollow(FOLLOW_expression_in_function2016);
                    	    expression74=expression();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_expression.add(expression74.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop29;
                        }
                    } while (true);


                    }


                    }
                    break;

            }

            RPAREN75=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_function2027); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN75);



            // AST REWRITE
            // elements: functionName, expression
            // token labels: 
            // rule labels: retval, functionName
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_functionName=new RewriteRuleSubtreeStream(adaptor,"token functionName",functionName!=null?functionName.tree:null);

            root_0 = (Object)adaptor.nil();
            // 312:3: -> ^( FunctionNode ^( NameNode $functionName) ( ^( ArrayNode ( expression )* ) )? )
            {
                // src/astudy/parser/sql/QTemplate.g:312:6: ^( FunctionNode ^( NameNode $functionName) ( ^( ArrayNode ( expression )* ) )? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FunctionNode, "FunctionNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:312:21: ^( NameNode $functionName)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_2);

                adaptor.addChild(root_2, stream_functionName.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                // src/astudy/parser/sql/QTemplate.g:312:47: ( ^( ArrayNode ( expression )* ) )?
                if ( stream_expression.hasNext() ) {
                    // src/astudy/parser/sql/QTemplate.g:312:47: ^( ArrayNode ( expression )* )
                    {
                    Object root_2 = (Object)adaptor.nil();
                    root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ArrayNode, "ArrayNode"), root_2);

                    // src/astudy/parser/sql/QTemplate.g:312:59: ( expression )*
                    while ( stream_expression.hasNext() ) {
                        adaptor.addChild(root_2, stream_expression.nextTree());

                    }
                    stream_expression.reset();

                    adaptor.addChild(root_1, root_2);
                    }

                }
                stream_expression.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "function"

    public static class constant_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "constant"
    // src/astudy/parser/sql/QTemplate.g:315:1: constant : ( ( PLUS | MINUS )? INTEGER | DECIMAL | FLOAT_POINT | CHARACTER_STRING | 'GRAPHIC_STRING' | 'BINARY-STRING' | 'DECIMAL_POINT' | 'Delimiters' );
    public final QTemplateParser.constant_return constant() throws RecognitionException {
        QTemplateParser.constant_return retval = new QTemplateParser.constant_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set76=null;
        Token INTEGER77=null;
        Token DECIMAL78=null;
        Token FLOAT_POINT79=null;
        Token CHARACTER_STRING80=null;
        Token string_literal81=null;
        Token string_literal82=null;
        Token string_literal83=null;
        Token string_literal84=null;

        Object set76_tree=null;
        Object INTEGER77_tree=null;
        Object DECIMAL78_tree=null;
        Object FLOAT_POINT79_tree=null;
        Object CHARACTER_STRING80_tree=null;
        Object string_literal81_tree=null;
        Object string_literal82_tree=null;
        Object string_literal83_tree=null;
        Object string_literal84_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:316:2: ( ( PLUS | MINUS )? INTEGER | DECIMAL | FLOAT_POINT | CHARACTER_STRING | 'GRAPHIC_STRING' | 'BINARY-STRING' | 'DECIMAL_POINT' | 'Delimiters' )
            int alt32=8;
            alt32 = dfa32.predict(input);
            switch (alt32) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:316:4: ( PLUS | MINUS )? INTEGER
                    {
                    root_0 = (Object)adaptor.nil();

                    // src/astudy/parser/sql/QTemplate.g:316:4: ( PLUS | MINUS )?
                    int alt31=2;
                    int LA31_0 = input.LA(1);

                    if ( ((LA31_0>=PLUS && LA31_0<=MINUS)) ) {
                        alt31=1;
                    }
                    switch (alt31) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:
                            {
                            set76=(Token)input.LT(1);
                            if ( (input.LA(1)>=PLUS && input.LA(1)<=MINUS) ) {
                                input.consume();
                                if ( state.backtracking==0 ) adaptor.addChild(root_0, (Object)adaptor.create(set76));
                                state.errorRecovery=false;state.failed=false;
                            }
                            else {
                                if (state.backtracking>0) {state.failed=true; return retval;}
                                MismatchedSetException mse = new MismatchedSetException(null,input);
                                throw mse;
                            }


                            }
                            break;

                    }

                    INTEGER77=(Token)match(input,INTEGER,FOLLOW_INTEGER_in_constant2068); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    INTEGER77_tree = (Object)adaptor.create(INTEGER77);
                    adaptor.addChild(root_0, INTEGER77_tree);
                    }

                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:317:3: DECIMAL
                    {
                    root_0 = (Object)adaptor.nil();

                    DECIMAL78=(Token)match(input,DECIMAL,FOLLOW_DECIMAL_in_constant2074); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    DECIMAL78_tree = (Object)adaptor.create(DECIMAL78);
                    adaptor.addChild(root_0, DECIMAL78_tree);
                    }

                    }
                    break;
                case 3 :
                    // src/astudy/parser/sql/QTemplate.g:318:3: FLOAT_POINT
                    {
                    root_0 = (Object)adaptor.nil();

                    FLOAT_POINT79=(Token)match(input,FLOAT_POINT,FOLLOW_FLOAT_POINT_in_constant2080); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    FLOAT_POINT79_tree = (Object)adaptor.create(FLOAT_POINT79);
                    adaptor.addChild(root_0, FLOAT_POINT79_tree);
                    }

                    }
                    break;
                case 4 :
                    // src/astudy/parser/sql/QTemplate.g:319:3: CHARACTER_STRING
                    {
                    root_0 = (Object)adaptor.nil();

                    CHARACTER_STRING80=(Token)match(input,CHARACTER_STRING,FOLLOW_CHARACTER_STRING_in_constant2086); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    CHARACTER_STRING80_tree = (Object)adaptor.create(CHARACTER_STRING80);
                    adaptor.addChild(root_0, CHARACTER_STRING80_tree);
                    }

                    }
                    break;
                case 5 :
                    // src/astudy/parser/sql/QTemplate.g:320:3: 'GRAPHIC_STRING'
                    {
                    root_0 = (Object)adaptor.nil();

                    string_literal81=(Token)match(input,124,FOLLOW_124_in_constant2092); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    string_literal81_tree = (Object)adaptor.create(string_literal81);
                    adaptor.addChild(root_0, string_literal81_tree);
                    }

                    }
                    break;
                case 6 :
                    // src/astudy/parser/sql/QTemplate.g:321:3: 'BINARY-STRING'
                    {
                    root_0 = (Object)adaptor.nil();

                    string_literal82=(Token)match(input,125,FOLLOW_125_in_constant2098); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    string_literal82_tree = (Object)adaptor.create(string_literal82);
                    adaptor.addChild(root_0, string_literal82_tree);
                    }

                    }
                    break;
                case 7 :
                    // src/astudy/parser/sql/QTemplate.g:322:3: 'DECIMAL_POINT'
                    {
                    root_0 = (Object)adaptor.nil();

                    string_literal83=(Token)match(input,126,FOLLOW_126_in_constant2104); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    string_literal83_tree = (Object)adaptor.create(string_literal83);
                    adaptor.addChild(root_0, string_literal83_tree);
                    }

                    }
                    break;
                case 8 :
                    // src/astudy/parser/sql/QTemplate.g:323:3: 'Delimiters'
                    {
                    root_0 = (Object)adaptor.nil();

                    string_literal84=(Token)match(input,127,FOLLOW_127_in_constant2110); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    string_literal84_tree = (Object)adaptor.create(string_literal84);
                    adaptor.addChild(root_0, string_literal84_tree);
                    }

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "constant"

    public static class specialRegister_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "specialRegister"
    // src/astudy/parser/sql/QTemplate.g:331:1: specialRegister : 'current date' ;
    public final QTemplateParser.specialRegister_return specialRegister() throws RecognitionException {
        QTemplateParser.specialRegister_return retval = new QTemplateParser.specialRegister_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token string_literal85=null;

        Object string_literal85_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:332:2: ( 'current date' )
            // src/astudy/parser/sql/QTemplate.g:332:4: 'current date'
            {
            root_0 = (Object)adaptor.nil();

            string_literal85=(Token)match(input,128,FOLLOW_128_in_specialRegister2122); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            string_literal85_tree = (Object)adaptor.create(string_literal85);
            adaptor.addChild(root_0, string_literal85_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "specialRegister"

    public static class scalarSubSelect_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "scalarSubSelect"
    // src/astudy/parser/sql/QTemplate.g:345:1: scalarSubSelect : subselect ;
    public final QTemplateParser.scalarSubSelect_return scalarSubSelect() throws RecognitionException {
        QTemplateParser.scalarSubSelect_return retval = new QTemplateParser.scalarSubSelect_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.subselect_return subselect86 = null;



        try {
            // src/astudy/parser/sql/QTemplate.g:346:2: ( subselect )
            // src/astudy/parser/sql/QTemplate.g:346:4: subselect
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_subselect_in_scalarSubSelect2135);
            subselect86=subselect();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) adaptor.addChild(root_0, subselect86.getTree());

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "scalarSubSelect"

    public static class labeledDuration_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "labeledDuration"
    // src/astudy/parser/sql/QTemplate.g:349:1: labeledDuration : ( function | LPAREN expression RPAREN | constant | columnName | ) IDENTIFIER ;
    public final QTemplateParser.labeledDuration_return labeledDuration() throws RecognitionException {
        QTemplateParser.labeledDuration_return retval = new QTemplateParser.labeledDuration_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LPAREN88=null;
        Token RPAREN90=null;
        Token IDENTIFIER93=null;
        QTemplateParser.function_return function87 = null;

        QTemplateParser.expression_return expression89 = null;

        QTemplateParser.constant_return constant91 = null;

        QTemplateParser.columnName_return columnName92 = null;


        Object LPAREN88_tree=null;
        Object RPAREN90_tree=null;
        Object IDENTIFIER93_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:350:2: ( ( function | LPAREN expression RPAREN | constant | columnName | ) IDENTIFIER )
            // src/astudy/parser/sql/QTemplate.g:350:4: ( function | LPAREN expression RPAREN | constant | columnName | ) IDENTIFIER
            {
            root_0 = (Object)adaptor.nil();

            // src/astudy/parser/sql/QTemplate.g:350:4: ( function | LPAREN expression RPAREN | constant | columnName | )
            int alt33=5;
            alt33 = dfa33.predict(input);
            switch (alt33) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:351:4: function
                    {
                    pushFollow(FOLLOW_function_in_labeledDuration2151);
                    function87=function();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, function87.getTree());

                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:352:4: LPAREN expression RPAREN
                    {
                    LPAREN88=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_labeledDuration2159); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    LPAREN88_tree = (Object)adaptor.create(LPAREN88);
                    adaptor.addChild(root_0, LPAREN88_tree);
                    }
                    pushFollow(FOLLOW_expression_in_labeledDuration2161);
                    expression89=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, expression89.getTree());
                    RPAREN90=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_labeledDuration2163); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    RPAREN90_tree = (Object)adaptor.create(RPAREN90);
                    adaptor.addChild(root_0, RPAREN90_tree);
                    }

                    }
                    break;
                case 3 :
                    // src/astudy/parser/sql/QTemplate.g:353:4: constant
                    {
                    pushFollow(FOLLOW_constant_in_labeledDuration2170);
                    constant91=constant();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, constant91.getTree());

                    }
                    break;
                case 4 :
                    // src/astudy/parser/sql/QTemplate.g:354:4: columnName
                    {
                    pushFollow(FOLLOW_columnName_in_labeledDuration2177);
                    columnName92=columnName();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, columnName92.getTree());

                    }
                    break;
                case 5 :
                    // src/astudy/parser/sql/QTemplate.g:356:3: 
                    {
                    }
                    break;

            }

            IDENTIFIER93=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_labeledDuration2189); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            IDENTIFIER93_tree = (Object)adaptor.create(IDENTIFIER93);
            adaptor.addChild(root_0, IDENTIFIER93_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "labeledDuration"

    public static class castSpecification_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "castSpecification"
    // src/astudy/parser/sql/QTemplate.g:360:1: castSpecification : CAST LPAREN exp= expression AS type= identifier ( LPAREN i+= INTEGER ( COMMA i+= INTEGER )? RPAREN )? RPAREN -> ^( CastNode $exp $type ( $i)+ ) ;
    public final QTemplateParser.castSpecification_return castSpecification() throws RecognitionException {
        QTemplateParser.castSpecification_return retval = new QTemplateParser.castSpecification_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token CAST94=null;
        Token LPAREN95=null;
        Token AS96=null;
        Token LPAREN97=null;
        Token COMMA98=null;
        Token RPAREN99=null;
        Token RPAREN100=null;
        Token i=null;
        List list_i=null;
        QTemplateParser.expression_return exp = null;

        QTemplateParser.identifier_return type = null;


        Object CAST94_tree=null;
        Object LPAREN95_tree=null;
        Object AS96_tree=null;
        Object LPAREN97_tree=null;
        Object COMMA98_tree=null;
        Object RPAREN99_tree=null;
        Object RPAREN100_tree=null;
        Object i_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_CAST=new RewriteRuleTokenStream(adaptor,"token CAST");
        RewriteRuleTokenStream stream_INTEGER=new RewriteRuleTokenStream(adaptor,"token INTEGER");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_AS=new RewriteRuleTokenStream(adaptor,"token AS");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:361:2: ( CAST LPAREN exp= expression AS type= identifier ( LPAREN i+= INTEGER ( COMMA i+= INTEGER )? RPAREN )? RPAREN -> ^( CastNode $exp $type ( $i)+ ) )
            // src/astudy/parser/sql/QTemplate.g:361:4: CAST LPAREN exp= expression AS type= identifier ( LPAREN i+= INTEGER ( COMMA i+= INTEGER )? RPAREN )? RPAREN
            {
            CAST94=(Token)match(input,CAST,FOLLOW_CAST_in_castSpecification2201); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_CAST.add(CAST94);

            LPAREN95=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_castSpecification2203); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN95);

            pushFollow(FOLLOW_expression_in_castSpecification2211);
            exp=expression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_expression.add(exp.getTree());
            AS96=(Token)match(input,AS,FOLLOW_AS_in_castSpecification2213); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_AS.add(AS96);

            pushFollow(FOLLOW_identifier_in_castSpecification2221);
            type=identifier();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_identifier.add(type.getTree());
            // src/astudy/parser/sql/QTemplate.g:363:20: ( LPAREN i+= INTEGER ( COMMA i+= INTEGER )? RPAREN )?
            int alt35=2;
            int LA35_0 = input.LA(1);

            if ( (LA35_0==LPAREN) ) {
                alt35=1;
            }
            switch (alt35) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:363:21: LPAREN i+= INTEGER ( COMMA i+= INTEGER )? RPAREN
                    {
                    LPAREN97=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_castSpecification2224); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN97);

                    i=(Token)match(input,INTEGER,FOLLOW_INTEGER_in_castSpecification2228); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_INTEGER.add(i);

                    if (list_i==null) list_i=new ArrayList();
                    list_i.add(i);

                    // src/astudy/parser/sql/QTemplate.g:363:39: ( COMMA i+= INTEGER )?
                    int alt34=2;
                    int LA34_0 = input.LA(1);

                    if ( (LA34_0==COMMA) ) {
                        alt34=1;
                    }
                    switch (alt34) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:363:40: COMMA i+= INTEGER
                            {
                            COMMA98=(Token)match(input,COMMA,FOLLOW_COMMA_in_castSpecification2231); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_COMMA.add(COMMA98);

                            i=(Token)match(input,INTEGER,FOLLOW_INTEGER_in_castSpecification2235); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_INTEGER.add(i);

                            if (list_i==null) list_i=new ArrayList();
                            list_i.add(i);


                            }
                            break;

                    }

                    RPAREN99=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_castSpecification2239); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN99);


                    }
                    break;

            }

            RPAREN100=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_castSpecification2246); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN100);



            // AST REWRITE
            // elements: i, type, exp
            // token labels: 
            // rule labels: exp, type, retval
            // token list labels: i
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleTokenStream stream_i=new RewriteRuleTokenStream(adaptor,"token i", list_i);
            RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
            RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"token type",type!=null?type.tree:null);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 365:3: -> ^( CastNode $exp $type ( $i)+ )
            {
                // src/astudy/parser/sql/QTemplate.g:365:6: ^( CastNode $exp $type ( $i)+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CastNode, "CastNode"), root_1);

                adaptor.addChild(root_1, stream_exp.nextTree());
                adaptor.addChild(root_1, stream_type.nextTree());
                if ( !(stream_i.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_i.hasNext() ) {
                    adaptor.addChild(root_1, stream_i.nextNode());

                }
                stream_i.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "castSpecification"

    public static class caseExpression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "caseExpression"
    // src/astudy/parser/sql/QTemplate.g:368:1: caseExpression : CASE (exp= expression ( WHEN i+= expression THEN i+= expression )+ | ( WHEN i+= searchCondition THEN i+= expression )+ ) ( ELSE j= expression )? END -> {exp == null}? ^( CaseNode ( $i)* ( $j)? ) -> ^( CaseExpressionNode ^( ExpressionNode $exp) ( $i)* ( $j)? ) ;
    public final QTemplateParser.caseExpression_return caseExpression() throws RecognitionException {
        QTemplateParser.caseExpression_return retval = new QTemplateParser.caseExpression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token CASE101=null;
        Token WHEN102=null;
        Token THEN103=null;
        Token WHEN104=null;
        Token THEN105=null;
        Token ELSE106=null;
        Token END107=null;
        List list_i=null;
        QTemplateParser.expression_return exp = null;

        QTemplateParser.expression_return j = null;

        RuleReturnScope i = null;
        Object CASE101_tree=null;
        Object WHEN102_tree=null;
        Object THEN103_tree=null;
        Object WHEN104_tree=null;
        Object THEN105_tree=null;
        Object ELSE106_tree=null;
        Object END107_tree=null;
        RewriteRuleTokenStream stream_CASE=new RewriteRuleTokenStream(adaptor,"token CASE");
        RewriteRuleTokenStream stream_THEN=new RewriteRuleTokenStream(adaptor,"token THEN");
        RewriteRuleTokenStream stream_ELSE=new RewriteRuleTokenStream(adaptor,"token ELSE");
        RewriteRuleTokenStream stream_END=new RewriteRuleTokenStream(adaptor,"token END");
        RewriteRuleTokenStream stream_WHEN=new RewriteRuleTokenStream(adaptor,"token WHEN");
        RewriteRuleSubtreeStream stream_searchCondition=new RewriteRuleSubtreeStream(adaptor,"rule searchCondition");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:369:2: ( CASE (exp= expression ( WHEN i+= expression THEN i+= expression )+ | ( WHEN i+= searchCondition THEN i+= expression )+ ) ( ELSE j= expression )? END -> {exp == null}? ^( CaseNode ( $i)* ( $j)? ) -> ^( CaseExpressionNode ^( ExpressionNode $exp) ( $i)* ( $j)? ) )
            // src/astudy/parser/sql/QTemplate.g:369:4: CASE (exp= expression ( WHEN i+= expression THEN i+= expression )+ | ( WHEN i+= searchCondition THEN i+= expression )+ ) ( ELSE j= expression )? END
            {
            CASE101=(Token)match(input,CASE,FOLLOW_CASE_in_caseExpression2276); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_CASE.add(CASE101);

            // src/astudy/parser/sql/QTemplate.g:369:10: (exp= expression ( WHEN i+= expression THEN i+= expression )+ | ( WHEN i+= searchCondition THEN i+= expression )+ )
            int alt38=2;
            alt38 = dfa38.predict(input);
            switch (alt38) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:370:4: exp= expression ( WHEN i+= expression THEN i+= expression )+
                    {
                    pushFollow(FOLLOW_expression_in_caseExpression2286);
                    exp=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expression.add(exp.getTree());
                    // src/astudy/parser/sql/QTemplate.g:370:19: ( WHEN i+= expression THEN i+= expression )+
                    int cnt36=0;
                    loop36:
                    do {
                        int alt36=2;
                        int LA36_0 = input.LA(1);

                        if ( (LA36_0==WHEN) ) {
                            alt36=1;
                        }


                        switch (alt36) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:370:20: WHEN i+= expression THEN i+= expression
                    	    {
                    	    WHEN102=(Token)match(input,WHEN,FOLLOW_WHEN_in_caseExpression2289); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_WHEN.add(WHEN102);

                    	    pushFollow(FOLLOW_expression_in_caseExpression2293);
                    	    i=expression();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_expression.add(i.getTree());
                    	    if (list_i==null) list_i=new ArrayList();
                    	    list_i.add(i.getTree());

                    	    THEN103=(Token)match(input,THEN,FOLLOW_THEN_in_caseExpression2295); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_THEN.add(THEN103);

                    	    pushFollow(FOLLOW_expression_in_caseExpression2299);
                    	    i=expression();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_expression.add(i.getTree());
                    	    if (list_i==null) list_i=new ArrayList();
                    	    list_i.add(i.getTree());


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt36 >= 1 ) break loop36;
                    	    if (state.backtracking>0) {state.failed=true; return retval;}
                                EarlyExitException eee =
                                    new EarlyExitException(36, input);
                                throw eee;
                        }
                        cnt36++;
                    } while (true);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:371:6: ( WHEN i+= searchCondition THEN i+= expression )+
                    {
                    // src/astudy/parser/sql/QTemplate.g:371:6: ( WHEN i+= searchCondition THEN i+= expression )+
                    int cnt37=0;
                    loop37:
                    do {
                        int alt37=2;
                        int LA37_0 = input.LA(1);

                        if ( (LA37_0==WHEN) ) {
                            alt37=1;
                        }


                        switch (alt37) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:371:7: WHEN i+= searchCondition THEN i+= expression
                    	    {
                    	    WHEN104=(Token)match(input,WHEN,FOLLOW_WHEN_in_caseExpression2309); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_WHEN.add(WHEN104);

                    	    pushFollow(FOLLOW_searchCondition_in_caseExpression2313);
                    	    i=searchCondition();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_searchCondition.add(i.getTree());
                    	    if (list_i==null) list_i=new ArrayList();
                    	    list_i.add(i.getTree());

                    	    THEN105=(Token)match(input,THEN,FOLLOW_THEN_in_caseExpression2315); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_THEN.add(THEN105);

                    	    pushFollow(FOLLOW_expression_in_caseExpression2319);
                    	    i=expression();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_expression.add(i.getTree());
                    	    if (list_i==null) list_i=new ArrayList();
                    	    list_i.add(i.getTree());


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt37 >= 1 ) break loop37;
                    	    if (state.backtracking>0) {state.failed=true; return retval;}
                                EarlyExitException eee =
                                    new EarlyExitException(37, input);
                                throw eee;
                        }
                        cnt37++;
                    } while (true);


                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:373:3: ( ELSE j= expression )?
            int alt39=2;
            int LA39_0 = input.LA(1);

            if ( (LA39_0==ELSE) ) {
                alt39=1;
            }
            switch (alt39) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:373:4: ELSE j= expression
                    {
                    ELSE106=(Token)match(input,ELSE,FOLLOW_ELSE_in_caseExpression2334); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ELSE.add(ELSE106);

                    pushFollow(FOLLOW_expression_in_caseExpression2338);
                    j=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expression.add(j.getTree());

                    }
                    break;

            }

            END107=(Token)match(input,END,FOLLOW_END_in_caseExpression2345); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_END.add(END107);



            // AST REWRITE
            // elements: i, j, j, exp, i
            // token labels: 
            // rule labels: exp, j, retval
            // token list labels: 
            // rule list labels: i
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
            RewriteRuleSubtreeStream stream_j=new RewriteRuleSubtreeStream(adaptor,"token j",j!=null?j.tree:null);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_i=new RewriteRuleSubtreeStream(adaptor,"token i",list_i);
            root_0 = (Object)adaptor.nil();
            // 375:3: -> {exp == null}? ^( CaseNode ( $i)* ( $j)? )
            if (exp == null) {
                // src/astudy/parser/sql/QTemplate.g:375:21: ^( CaseNode ( $i)* ( $j)? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CaseNode, "CaseNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:375:32: ( $i)*
                while ( stream_i.hasNext() ) {
                    adaptor.addChild(root_1, stream_i.nextTree());

                }
                stream_i.reset();
                // src/astudy/parser/sql/QTemplate.g:375:36: ( $j)?
                if ( stream_j.hasNext() ) {
                    adaptor.addChild(root_1, stream_j.nextTree());

                }
                stream_j.reset();

                adaptor.addChild(root_0, root_1);
                }

            }
            else // 376:3: -> ^( CaseExpressionNode ^( ExpressionNode $exp) ( $i)* ( $j)? )
            {
                // src/astudy/parser/sql/QTemplate.g:376:6: ^( CaseExpressionNode ^( ExpressionNode $exp) ( $i)* ( $j)? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CaseExpressionNode, "CaseExpressionNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:376:27: ^( ExpressionNode $exp)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ExpressionNode, "ExpressionNode"), root_2);

                adaptor.addChild(root_2, stream_exp.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                // src/astudy/parser/sql/QTemplate.g:376:50: ( $i)*
                while ( stream_i.hasNext() ) {
                    adaptor.addChild(root_1, stream_i.nextTree());

                }
                stream_i.reset();
                // src/astudy/parser/sql/QTemplate.g:376:54: ( $j)?
                if ( stream_j.hasNext() ) {
                    adaptor.addChild(root_1, stream_j.nextTree());

                }
                stream_j.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "caseExpression"

    public static class compareOperator_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "compareOperator"
    // src/astudy/parser/sql/QTemplate.g:379:1: compareOperator : ( EQ | NE | LE | GT | NL | NG ) ;
    public final QTemplateParser.compareOperator_return compareOperator() throws RecognitionException {
        QTemplateParser.compareOperator_return retval = new QTemplateParser.compareOperator_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set108=null;

        Object set108_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:380:2: ( ( EQ | NE | LE | GT | NL | NG ) )
            // src/astudy/parser/sql/QTemplate.g:380:5: ( EQ | NE | LE | GT | NL | NG )
            {
            root_0 = (Object)adaptor.nil();

            set108=(Token)input.LT(1);
            if ( (input.LA(1)>=EQ && input.LA(1)<=NG) ) {
                input.consume();
                if ( state.backtracking==0 ) adaptor.addChild(root_0, (Object)adaptor.create(set108));
                state.errorRecovery=false;state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "compareOperator"

    public static class unaryOperator_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "unaryOperator"
    // src/astudy/parser/sql/QTemplate.g:383:1: unaryOperator : ( PLUS | MINUS );
    public final QTemplateParser.unaryOperator_return unaryOperator() throws RecognitionException {
        QTemplateParser.unaryOperator_return retval = new QTemplateParser.unaryOperator_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set109=null;

        Object set109_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:384:2: ( PLUS | MINUS )
            // src/astudy/parser/sql/QTemplate.g:
            {
            root_0 = (Object)adaptor.nil();

            set109=(Token)input.LT(1);
            if ( (input.LA(1)>=PLUS && input.LA(1)<=MINUS) ) {
                input.consume();
                if ( state.backtracking==0 ) adaptor.addChild(root_0, (Object)adaptor.create(set109));
                state.errorRecovery=false;state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "unaryOperator"

    public static class binaryOperator_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "binaryOperator"
    // src/astudy/parser/sql/QTemplate.g:387:1: binaryOperator : ( arithmeticOperator | bitwiseOperator );
    public final QTemplateParser.binaryOperator_return binaryOperator() throws RecognitionException {
        QTemplateParser.binaryOperator_return retval = new QTemplateParser.binaryOperator_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.arithmeticOperator_return arithmeticOperator110 = null;

        QTemplateParser.bitwiseOperator_return bitwiseOperator111 = null;



        try {
            // src/astudy/parser/sql/QTemplate.g:388:2: ( arithmeticOperator | bitwiseOperator )
            int alt40=2;
            int LA40_0 = input.LA(1);

            if ( (LA40_0==CONCAT||(LA40_0>=DOUBLE_STAR && LA40_0<=STAR)||(LA40_0>=PLUS && LA40_0<=MINUS)||LA40_0==DIVIDE) ) {
                alt40=1;
            }
            else if ( (LA40_0==DOUBLE_BITWISEOR) ) {
                alt40=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 40, 0, input);

                throw nvae;
            }
            switch (alt40) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:388:5: arithmeticOperator
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_arithmeticOperator_in_binaryOperator2441);
                    arithmeticOperator110=arithmeticOperator();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, arithmeticOperator110.getTree());

                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:388:26: bitwiseOperator
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_bitwiseOperator_in_binaryOperator2445);
                    bitwiseOperator111=bitwiseOperator();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, bitwiseOperator111.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "binaryOperator"

    public static class arithmeticOperator_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "arithmeticOperator"
    // src/astudy/parser/sql/QTemplate.g:391:1: arithmeticOperator : ( CONCAT | DIVIDE | STAR | DOUBLE_STAR | PLUS | MINUS );
    public final QTemplateParser.arithmeticOperator_return arithmeticOperator() throws RecognitionException {
        QTemplateParser.arithmeticOperator_return retval = new QTemplateParser.arithmeticOperator_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token set112=null;

        Object set112_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:392:2: ( CONCAT | DIVIDE | STAR | DOUBLE_STAR | PLUS | MINUS )
            // src/astudy/parser/sql/QTemplate.g:
            {
            root_0 = (Object)adaptor.nil();

            set112=(Token)input.LT(1);
            if ( input.LA(1)==CONCAT||(input.LA(1)>=DOUBLE_STAR && input.LA(1)<=STAR)||(input.LA(1)>=PLUS && input.LA(1)<=MINUS)||input.LA(1)==DIVIDE ) {
                input.consume();
                if ( state.backtracking==0 ) adaptor.addChild(root_0, (Object)adaptor.create(set112));
                state.errorRecovery=false;state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "arithmeticOperator"

    public static class bitwiseOperator_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "bitwiseOperator"
    // src/astudy/parser/sql/QTemplate.g:400:1: bitwiseOperator : DOUBLE_BITWISEOR ;
    public final QTemplateParser.bitwiseOperator_return bitwiseOperator() throws RecognitionException {
        QTemplateParser.bitwiseOperator_return retval = new QTemplateParser.bitwiseOperator_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token DOUBLE_BITWISEOR113=null;

        Object DOUBLE_BITWISEOR113_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:401:2: ( DOUBLE_BITWISEOR )
            // src/astudy/parser/sql/QTemplate.g:401:4: DOUBLE_BITWISEOR
            {
            root_0 = (Object)adaptor.nil();

            DOUBLE_BITWISEOR113=(Token)match(input,DOUBLE_BITWISEOR,FOLLOW_DOUBLE_BITWISEOR_in_bitwiseOperator2502); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            DOUBLE_BITWISEOR113_tree = (Object)adaptor.create(DOUBLE_BITWISEOR113);
            adaptor.addChild(root_0, DOUBLE_BITWISEOR113_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "bitwiseOperator"

    public static class fromClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "fromClause"
    // src/astudy/parser/sql/QTemplate.g:404:1: fromClause : FROM tableReference ( COMMA tableReference )* -> ^( TablesNode ( tableReference )+ ) ;
    public final QTemplateParser.fromClause_return fromClause() throws RecognitionException {
        QTemplateParser.fromClause_return retval = new QTemplateParser.fromClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token FROM114=null;
        Token COMMA116=null;
        QTemplateParser.tableReference_return tableReference115 = null;

        QTemplateParser.tableReference_return tableReference117 = null;


        Object FROM114_tree=null;
        Object COMMA116_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_FROM=new RewriteRuleTokenStream(adaptor,"token FROM");
        RewriteRuleSubtreeStream stream_tableReference=new RewriteRuleSubtreeStream(adaptor,"rule tableReference");
        try {
            // src/astudy/parser/sql/QTemplate.g:405:2: ( FROM tableReference ( COMMA tableReference )* -> ^( TablesNode ( tableReference )+ ) )
            // src/astudy/parser/sql/QTemplate.g:405:4: FROM tableReference ( COMMA tableReference )*
            {
            FROM114=(Token)match(input,FROM,FOLLOW_FROM_in_fromClause2513); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_FROM.add(FROM114);

            pushFollow(FOLLOW_tableReference_in_fromClause2515);
            tableReference115=tableReference();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_tableReference.add(tableReference115.getTree());
            // src/astudy/parser/sql/QTemplate.g:405:24: ( COMMA tableReference )*
            loop41:
            do {
                int alt41=2;
                alt41 = dfa41.predict(input);
                switch (alt41) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:405:25: COMMA tableReference
            	    {
            	    COMMA116=(Token)match(input,COMMA,FOLLOW_COMMA_in_fromClause2518); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA116);

            	    pushFollow(FOLLOW_tableReference_in_fromClause2520);
            	    tableReference117=tableReference();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_tableReference.add(tableReference117.getTree());

            	    }
            	    break;

            	default :
            	    break loop41;
                }
            } while (true);



            // AST REWRITE
            // elements: tableReference
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 406:3: -> ^( TablesNode ( tableReference )+ )
            {
                // src/astudy/parser/sql/QTemplate.g:406:6: ^( TablesNode ( tableReference )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(TablesNode, "TablesNode"), root_1);

                if ( !(stream_tableReference.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_tableReference.hasNext() ) {
                    adaptor.addChild(root_1, stream_tableReference.nextTree());

                }
                stream_tableReference.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "fromClause"

    public static class singleTable_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "singleTable"
    // src/astudy/parser/sql/QTemplate.g:409:1: singleTable : refid= identifier (refcol= correlationClause )? -> ^( TableNode ^( NameNode $refid) ( ^( AliasNode $refcol) )? ) ;
    public final QTemplateParser.singleTable_return singleTable() throws RecognitionException {
        QTemplateParser.singleTable_return retval = new QTemplateParser.singleTable_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.identifier_return refid = null;

        QTemplateParser.correlationClause_return refcol = null;


        RewriteRuleSubtreeStream stream_correlationClause=new RewriteRuleSubtreeStream(adaptor,"rule correlationClause");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        try {
            // src/astudy/parser/sql/QTemplate.g:410:2: (refid= identifier (refcol= correlationClause )? -> ^( TableNode ^( NameNode $refid) ( ^( AliasNode $refcol) )? ) )
            // src/astudy/parser/sql/QTemplate.g:410:4: refid= identifier (refcol= correlationClause )?
            {
            pushFollow(FOLLOW_identifier_in_singleTable2547);
            refid=identifier();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_identifier.add(refid.getTree());
            // src/astudy/parser/sql/QTemplate.g:410:40: (refcol= correlationClause )?
            int alt42=2;
            alt42 = dfa42.predict(input);
            switch (alt42) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:410:41: refcol= correlationClause
                    {
                    pushFollow(FOLLOW_correlationClause_in_singleTable2553);
                    refcol=correlationClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_correlationClause.add(refcol.getTree());

                    }
                    break;

            }



            // AST REWRITE
            // elements: refid, refcol
            // token labels: 
            // rule labels: retval, refid, refcol
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_refid=new RewriteRuleSubtreeStream(adaptor,"token refid",refid!=null?refid.tree:null);
            RewriteRuleSubtreeStream stream_refcol=new RewriteRuleSubtreeStream(adaptor,"token refcol",refcol!=null?refcol.tree:null);

            root_0 = (Object)adaptor.nil();
            // 411:3: -> ^( TableNode ^( NameNode $refid) ( ^( AliasNode $refcol) )? )
            {
                // src/astudy/parser/sql/QTemplate.g:411:6: ^( TableNode ^( NameNode $refid) ( ^( AliasNode $refcol) )? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(TableNode, "TableNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:411:18: ^( NameNode $refid)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_2);

                adaptor.addChild(root_2, stream_refid.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                // src/astudy/parser/sql/QTemplate.g:411:37: ( ^( AliasNode $refcol) )?
                if ( stream_refcol.hasNext() ) {
                    // src/astudy/parser/sql/QTemplate.g:411:37: ^( AliasNode $refcol)
                    {
                    Object root_2 = (Object)adaptor.nil();
                    root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(AliasNode, "AliasNode"), root_2);

                    adaptor.addChild(root_2, stream_refcol.nextTree());

                    adaptor.addChild(root_1, root_2);
                    }

                }
                stream_refcol.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "singleTable"

    public static class nestedTableExpression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "nestedTableExpression"
    // src/astudy/parser/sql/QTemplate.g:414:1: nestedTableExpression : LPAREN fullselect ( orderByClause )? ( fetchFirstClause )? RPAREN refid= correlationClause -> ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? ) ;
    public final QTemplateParser.nestedTableExpression_return nestedTableExpression() throws RecognitionException {
        QTemplateParser.nestedTableExpression_return retval = new QTemplateParser.nestedTableExpression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LPAREN118=null;
        Token RPAREN122=null;
        QTemplateParser.correlationClause_return refid = null;

        QTemplateParser.fullselect_return fullselect119 = null;

        QTemplateParser.orderByClause_return orderByClause120 = null;

        QTemplateParser.fetchFirstClause_return fetchFirstClause121 = null;


        Object LPAREN118_tree=null;
        Object RPAREN122_tree=null;
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleSubtreeStream stream_correlationClause=new RewriteRuleSubtreeStream(adaptor,"rule correlationClause");
        RewriteRuleSubtreeStream stream_fullselect=new RewriteRuleSubtreeStream(adaptor,"rule fullselect");
        RewriteRuleSubtreeStream stream_orderByClause=new RewriteRuleSubtreeStream(adaptor,"rule orderByClause");
        RewriteRuleSubtreeStream stream_fetchFirstClause=new RewriteRuleSubtreeStream(adaptor,"rule fetchFirstClause");
        try {
            // src/astudy/parser/sql/QTemplate.g:415:2: ( LPAREN fullselect ( orderByClause )? ( fetchFirstClause )? RPAREN refid= correlationClause -> ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? ) )
            // src/astudy/parser/sql/QTemplate.g:415:4: LPAREN fullselect ( orderByClause )? ( fetchFirstClause )? RPAREN refid= correlationClause
            {
            LPAREN118=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_nestedTableExpression2591); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN118);

            pushFollow(FOLLOW_fullselect_in_nestedTableExpression2597);
            fullselect119=fullselect();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_fullselect.add(fullselect119.getTree());
            // src/astudy/parser/sql/QTemplate.g:416:15: ( orderByClause )?
            int alt43=2;
            int LA43_0 = input.LA(1);

            if ( (LA43_0==ORDER) ) {
                alt43=1;
            }
            switch (alt43) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:416:15: orderByClause
                    {
                    pushFollow(FOLLOW_orderByClause_in_nestedTableExpression2599);
                    orderByClause120=orderByClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_orderByClause.add(orderByClause120.getTree());

                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:416:30: ( fetchFirstClause )?
            int alt44=2;
            int LA44_0 = input.LA(1);

            if ( (LA44_0==FETCH) ) {
                alt44=1;
            }
            switch (alt44) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:416:30: fetchFirstClause
                    {
                    pushFollow(FOLLOW_fetchFirstClause_in_nestedTableExpression2602);
                    fetchFirstClause121=fetchFirstClause();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_fetchFirstClause.add(fetchFirstClause121.getTree());

                    }
                    break;

            }

            RPAREN122=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_nestedTableExpression2608); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN122);

            pushFollow(FOLLOW_correlationClause_in_nestedTableExpression2615);
            refid=correlationClause();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_correlationClause.add(refid.getTree());


            // AST REWRITE
            // elements: fetchFirstClause, orderByClause, refid, fullselect
            // token labels: 
            // rule labels: retval, refid
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_refid=new RewriteRuleSubtreeStream(adaptor,"token refid",refid!=null?refid.tree:null);

            root_0 = (Object)adaptor.nil();
            // 419:3: -> ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? )
            {
                // src/astudy/parser/sql/QTemplate.g:419:6: ^( SubQueryNode ^( NameNode $refid) fullselect ( orderByClause )? ( fetchFirstClause )? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(SubQueryNode, "SubQueryNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:419:21: ^( NameNode $refid)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(NameNode, "NameNode"), root_2);

                adaptor.addChild(root_2, stream_refid.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                adaptor.addChild(root_1, stream_fullselect.nextTree());
                // src/astudy/parser/sql/QTemplate.g:419:51: ( orderByClause )?
                if ( stream_orderByClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_orderByClause.nextTree());

                }
                stream_orderByClause.reset();
                // src/astudy/parser/sql/QTemplate.g:419:66: ( fetchFirstClause )?
                if ( stream_fetchFirstClause.hasNext() ) {
                    adaptor.addChild(root_1, stream_fetchFirstClause.nextTree());

                }
                stream_fetchFirstClause.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "nestedTableExpression"

    public static class tableFunction_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "tableFunction"
    // src/astudy/parser/sql/QTemplate.g:422:1: tableFunction : TABLE LPAREN name= identifier LPAREN (params+= expression ( COMMA params+= expression )* )? RPAREN RPAREN ref_table= correlationClause -> ^( TableNode ^( TableFunctionNode $name ( $params)* ) ^( AliasNode $ref_table) ) ;
    public final QTemplateParser.tableFunction_return tableFunction() throws RecognitionException {
        QTemplateParser.tableFunction_return retval = new QTemplateParser.tableFunction_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token TABLE123=null;
        Token LPAREN124=null;
        Token LPAREN125=null;
        Token COMMA126=null;
        Token RPAREN127=null;
        Token RPAREN128=null;
        List list_params=null;
        QTemplateParser.identifier_return name = null;

        QTemplateParser.correlationClause_return ref_table = null;

        RuleReturnScope params = null;
        Object TABLE123_tree=null;
        Object LPAREN124_tree=null;
        Object LPAREN125_tree=null;
        Object COMMA126_tree=null;
        Object RPAREN127_tree=null;
        Object RPAREN128_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_TABLE=new RewriteRuleTokenStream(adaptor,"token TABLE");
        RewriteRuleSubtreeStream stream_correlationClause=new RewriteRuleSubtreeStream(adaptor,"rule correlationClause");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:423:2: ( TABLE LPAREN name= identifier LPAREN (params+= expression ( COMMA params+= expression )* )? RPAREN RPAREN ref_table= correlationClause -> ^( TableNode ^( TableFunctionNode $name ( $params)* ) ^( AliasNode $ref_table) ) )
            // src/astudy/parser/sql/QTemplate.g:423:4: TABLE LPAREN name= identifier LPAREN (params+= expression ( COMMA params+= expression )* )? RPAREN RPAREN ref_table= correlationClause
            {
            TABLE123=(Token)match(input,TABLE,FOLLOW_TABLE_in_tableFunction2649); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_TABLE.add(TABLE123);

            LPAREN124=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_tableFunction2651); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN124);

            pushFollow(FOLLOW_identifier_in_tableFunction2659);
            name=identifier();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_identifier.add(name.getTree());
            LPAREN125=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_tableFunction2665); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN125);

            // src/astudy/parser/sql/QTemplate.g:425:11: (params+= expression ( COMMA params+= expression )* )?
            int alt46=2;
            alt46 = dfa46.predict(input);
            switch (alt46) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:425:12: params+= expression ( COMMA params+= expression )*
                    {
                    pushFollow(FOLLOW_expression_in_tableFunction2670);
                    params=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expression.add(params.getTree());
                    if (list_params==null) list_params=new ArrayList();
                    list_params.add(params.getTree());

                    // src/astudy/parser/sql/QTemplate.g:425:31: ( COMMA params+= expression )*
                    loop45:
                    do {
                        int alt45=2;
                        int LA45_0 = input.LA(1);

                        if ( (LA45_0==COMMA) ) {
                            alt45=1;
                        }


                        switch (alt45) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:425:32: COMMA params+= expression
                    	    {
                    	    COMMA126=(Token)match(input,COMMA,FOLLOW_COMMA_in_tableFunction2673); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA126);

                    	    pushFollow(FOLLOW_expression_in_tableFunction2677);
                    	    params=expression();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_expression.add(params.getTree());
                    	    if (list_params==null) list_params=new ArrayList();
                    	    list_params.add(params.getTree());


                    	    }
                    	    break;

                    	default :
                    	    break loop45;
                        }
                    } while (true);


                    }
                    break;

            }

            RPAREN127=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_tableFunction2683); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN127);

            RPAREN128=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_tableFunction2688); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN128);

            pushFollow(FOLLOW_correlationClause_in_tableFunction2692);
            ref_table=correlationClause();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_correlationClause.add(ref_table.getTree());


            // AST REWRITE
            // elements: name, params, ref_table
            // token labels: 
            // rule labels: ref_table, retval, name
            // token list labels: 
            // rule list labels: params
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_ref_table=new RewriteRuleSubtreeStream(adaptor,"token ref_table",ref_table!=null?ref_table.tree:null);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_name=new RewriteRuleSubtreeStream(adaptor,"token name",name!=null?name.tree:null);
            RewriteRuleSubtreeStream stream_params=new RewriteRuleSubtreeStream(adaptor,"token params",list_params);
            root_0 = (Object)adaptor.nil();
            // 427:3: -> ^( TableNode ^( TableFunctionNode $name ( $params)* ) ^( AliasNode $ref_table) )
            {
                // src/astudy/parser/sql/QTemplate.g:427:6: ^( TableNode ^( TableFunctionNode $name ( $params)* ) ^( AliasNode $ref_table) )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(TableNode, "TableNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:427:18: ^( TableFunctionNode $name ( $params)* )
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(TableFunctionNode, "TableFunctionNode"), root_2);

                adaptor.addChild(root_2, stream_name.nextTree());
                // src/astudy/parser/sql/QTemplate.g:427:44: ( $params)*
                while ( stream_params.hasNext() ) {
                    adaptor.addChild(root_2, stream_params.nextTree());

                }
                stream_params.reset();

                adaptor.addChild(root_1, root_2);
                }
                // src/astudy/parser/sql/QTemplate.g:427:54: ^( AliasNode $ref_table)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(AliasNode, "AliasNode"), root_2);

                adaptor.addChild(root_2, stream_ref_table.nextTree());

                adaptor.addChild(root_1, root_2);
                }

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "tableFunction"

    public static class tableReference_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "tableReference"
    // src/astudy/parser/sql/QTemplate.g:430:1: tableReference : ( ( joinedTable | singleTable | nestedTableExpression | tableFunction ) tableReference )? ;
    public final QTemplateParser.tableReference_return tableReference() throws RecognitionException {
        QTemplateParser.tableReference_return retval = new QTemplateParser.tableReference_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.joinedTable_return joinedTable129 = null;

        QTemplateParser.singleTable_return singleTable130 = null;

        QTemplateParser.nestedTableExpression_return nestedTableExpression131 = null;

        QTemplateParser.tableFunction_return tableFunction132 = null;

        QTemplateParser.tableReference_return tableReference133 = null;



        try {
            // src/astudy/parser/sql/QTemplate.g:431:2: ( ( ( joinedTable | singleTable | nestedTableExpression | tableFunction ) tableReference )? )
            // src/astudy/parser/sql/QTemplate.g:431:4: ( ( joinedTable | singleTable | nestedTableExpression | tableFunction ) tableReference )?
            {
            root_0 = (Object)adaptor.nil();

            // src/astudy/parser/sql/QTemplate.g:431:4: ( ( joinedTable | singleTable | nestedTableExpression | tableFunction ) tableReference )?
            int alt48=2;
            alt48 = dfa48.predict(input);
            switch (alt48) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:432:4: ( joinedTable | singleTable | nestedTableExpression | tableFunction ) tableReference
                    {
                    // src/astudy/parser/sql/QTemplate.g:432:4: ( joinedTable | singleTable | nestedTableExpression | tableFunction )
                    int alt47=4;
                    alt47 = dfa47.predict(input);
                    switch (alt47) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:433:5: joinedTable
                            {
                            pushFollow(FOLLOW_joinedTable_in_tableReference2741);
                            joinedTable129=joinedTable();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) adaptor.addChild(root_0, joinedTable129.getTree());

                            }
                            break;
                        case 2 :
                            // src/astudy/parser/sql/QTemplate.g:434:7: singleTable
                            {
                            pushFollow(FOLLOW_singleTable_in_tableReference2749);
                            singleTable130=singleTable();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) adaptor.addChild(root_0, singleTable130.getTree());

                            }
                            break;
                        case 3 :
                            // src/astudy/parser/sql/QTemplate.g:435:7: nestedTableExpression
                            {
                            pushFollow(FOLLOW_nestedTableExpression_in_tableReference2757);
                            nestedTableExpression131=nestedTableExpression();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) adaptor.addChild(root_0, nestedTableExpression131.getTree());

                            }
                            break;
                        case 4 :
                            // src/astudy/parser/sql/QTemplate.g:436:7: tableFunction
                            {
                            pushFollow(FOLLOW_tableFunction_in_tableReference2765);
                            tableFunction132=tableFunction();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) adaptor.addChild(root_0, tableFunction132.getTree());

                            }
                            break;

                    }

                    pushFollow(FOLLOW_tableReference_in_tableReference2773);
                    tableReference133=tableReference();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, tableReference133.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "tableReference"

    public static class joinedTable_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "joinedTable"
    // src/astudy/parser/sql/QTemplate.g:442:1: joinedTable : ( CROSS JOIN tableReference -> ^( CrossJoinNode tableReference ) | (inner= INNER | (dir= LEFT | dir= RIGHT ) ( OUTER )? | (dir= LEFT | dir= RIGHT )? exception= EXCEPTION )? JOIN tableReference ON searchCondition -> {inner != null}? ^( InnerJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {exception != null && dir == null}? ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {exception != null && \"left\".equalsIgnoreCase(dir.getText())}? ^( LeftExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {exception != null && \"right\".equalsIgnoreCase(dir.getText())}? ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {dir == null}? ^( JoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {\"left\".equalsIgnoreCase(dir.getText())}? ^( LeftJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {\"right\".equalsIgnoreCase(dir.getText())}? ^( RightJoinNode tableReference ^( ConditionsNode searchCondition ) ) ->);
    public final QTemplateParser.joinedTable_return joinedTable() throws RecognitionException {
        QTemplateParser.joinedTable_return retval = new QTemplateParser.joinedTable_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token inner=null;
        Token dir=null;
        Token exception=null;
        Token CROSS134=null;
        Token JOIN135=null;
        Token OUTER137=null;
        Token JOIN138=null;
        Token ON140=null;
        QTemplateParser.tableReference_return tableReference136 = null;

        QTemplateParser.tableReference_return tableReference139 = null;

        QTemplateParser.searchCondition_return searchCondition141 = null;


        Object inner_tree=null;
        Object dir_tree=null;
        Object exception_tree=null;
        Object CROSS134_tree=null;
        Object JOIN135_tree=null;
        Object OUTER137_tree=null;
        Object JOIN138_tree=null;
        Object ON140_tree=null;
        RewriteRuleTokenStream stream_INNER=new RewriteRuleTokenStream(adaptor,"token INNER");
        RewriteRuleTokenStream stream_LEFT=new RewriteRuleTokenStream(adaptor,"token LEFT");
        RewriteRuleTokenStream stream_RIGHT=new RewriteRuleTokenStream(adaptor,"token RIGHT");
        RewriteRuleTokenStream stream_JOIN=new RewriteRuleTokenStream(adaptor,"token JOIN");
        RewriteRuleTokenStream stream_OUTER=new RewriteRuleTokenStream(adaptor,"token OUTER");
        RewriteRuleTokenStream stream_ON=new RewriteRuleTokenStream(adaptor,"token ON");
        RewriteRuleTokenStream stream_CROSS=new RewriteRuleTokenStream(adaptor,"token CROSS");
        RewriteRuleTokenStream stream_EXCEPTION=new RewriteRuleTokenStream(adaptor,"token EXCEPTION");
        RewriteRuleSubtreeStream stream_searchCondition=new RewriteRuleSubtreeStream(adaptor,"rule searchCondition");
        RewriteRuleSubtreeStream stream_tableReference=new RewriteRuleSubtreeStream(adaptor,"rule tableReference");
        try {
            // src/astudy/parser/sql/QTemplate.g:442:13: ( CROSS JOIN tableReference -> ^( CrossJoinNode tableReference ) | (inner= INNER | (dir= LEFT | dir= RIGHT ) ( OUTER )? | (dir= LEFT | dir= RIGHT )? exception= EXCEPTION )? JOIN tableReference ON searchCondition -> {inner != null}? ^( InnerJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {exception != null && dir == null}? ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {exception != null && \"left\".equalsIgnoreCase(dir.getText())}? ^( LeftExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {exception != null && \"right\".equalsIgnoreCase(dir.getText())}? ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {dir == null}? ^( JoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {\"left\".equalsIgnoreCase(dir.getText())}? ^( LeftJoinNode tableReference ^( ConditionsNode searchCondition ) ) -> {\"right\".equalsIgnoreCase(dir.getText())}? ^( RightJoinNode tableReference ^( ConditionsNode searchCondition ) ) ->)
            int alt53=2;
            int LA53_0 = input.LA(1);

            if ( (LA53_0==CROSS) ) {
                alt53=1;
            }
            else if ( ((LA53_0>=JOIN && LA53_0<=RIGHT)||LA53_0==EXCEPTION) ) {
                alt53=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 53, 0, input);

                throw nvae;
            }
            switch (alt53) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:443:3: CROSS JOIN tableReference
                    {
                    CROSS134=(Token)match(input,CROSS,FOLLOW_CROSS_in_joinedTable2793); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_CROSS.add(CROSS134);

                    JOIN135=(Token)match(input,JOIN,FOLLOW_JOIN_in_joinedTable2795); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_JOIN.add(JOIN135);

                    pushFollow(FOLLOW_tableReference_in_joinedTable2797);
                    tableReference136=tableReference();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_tableReference.add(tableReference136.getTree());


                    // AST REWRITE
                    // elements: tableReference
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 444:3: -> ^( CrossJoinNode tableReference )
                    {
                        // src/astudy/parser/sql/QTemplate.g:444:6: ^( CrossJoinNode tableReference )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CrossJoinNode, "CrossJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:445:5: (inner= INNER | (dir= LEFT | dir= RIGHT ) ( OUTER )? | (dir= LEFT | dir= RIGHT )? exception= EXCEPTION )? JOIN tableReference ON searchCondition
                    {
                    // src/astudy/parser/sql/QTemplate.g:445:5: (inner= INNER | (dir= LEFT | dir= RIGHT ) ( OUTER )? | (dir= LEFT | dir= RIGHT )? exception= EXCEPTION )?
                    int alt52=4;
                    alt52 = dfa52.predict(input);
                    switch (alt52) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:446:4: inner= INNER
                            {
                            inner=(Token)match(input,INNER,FOLLOW_INNER_in_joinedTable2821); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_INNER.add(inner);


                            }
                            break;
                        case 2 :
                            // src/astudy/parser/sql/QTemplate.g:447:6: (dir= LEFT | dir= RIGHT ) ( OUTER )?
                            {
                            // src/astudy/parser/sql/QTemplate.g:447:6: (dir= LEFT | dir= RIGHT )
                            int alt49=2;
                            int LA49_0 = input.LA(1);

                            if ( (LA49_0==LEFT) ) {
                                alt49=1;
                            }
                            else if ( (LA49_0==RIGHT) ) {
                                alt49=2;
                            }
                            else {
                                if (state.backtracking>0) {state.failed=true; return retval;}
                                NoViableAltException nvae =
                                    new NoViableAltException("", 49, 0, input);

                                throw nvae;
                            }
                            switch (alt49) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:447:7: dir= LEFT
                                    {
                                    dir=(Token)match(input,LEFT,FOLLOW_LEFT_in_joinedTable2831); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_LEFT.add(dir);


                                    }
                                    break;
                                case 2 :
                                    // src/astudy/parser/sql/QTemplate.g:447:16: dir= RIGHT
                                    {
                                    dir=(Token)match(input,RIGHT,FOLLOW_RIGHT_in_joinedTable2835); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_RIGHT.add(dir);


                                    }
                                    break;

                            }

                            // src/astudy/parser/sql/QTemplate.g:447:27: ( OUTER )?
                            int alt50=2;
                            int LA50_0 = input.LA(1);

                            if ( (LA50_0==OUTER) ) {
                                alt50=1;
                            }
                            switch (alt50) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:447:27: OUTER
                                    {
                                    OUTER137=(Token)match(input,OUTER,FOLLOW_OUTER_in_joinedTable2838); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_OUTER.add(OUTER137);


                                    }
                                    break;

                            }


                            }
                            break;
                        case 3 :
                            // src/astudy/parser/sql/QTemplate.g:448:6: (dir= LEFT | dir= RIGHT )? exception= EXCEPTION
                            {
                            // src/astudy/parser/sql/QTemplate.g:448:6: (dir= LEFT | dir= RIGHT )?
                            int alt51=3;
                            int LA51_0 = input.LA(1);

                            if ( (LA51_0==LEFT) ) {
                                alt51=1;
                            }
                            else if ( (LA51_0==RIGHT) ) {
                                alt51=2;
                            }
                            switch (alt51) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:448:7: dir= LEFT
                                    {
                                    dir=(Token)match(input,LEFT,FOLLOW_LEFT_in_joinedTable2849); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_LEFT.add(dir);


                                    }
                                    break;
                                case 2 :
                                    // src/astudy/parser/sql/QTemplate.g:448:16: dir= RIGHT
                                    {
                                    dir=(Token)match(input,RIGHT,FOLLOW_RIGHT_in_joinedTable2853); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_RIGHT.add(dir);


                                    }
                                    break;

                            }

                            exception=(Token)match(input,EXCEPTION,FOLLOW_EXCEPTION_in_joinedTable2859); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_EXCEPTION.add(exception);


                            }
                            break;

                    }

                    JOIN138=(Token)match(input,JOIN,FOLLOW_JOIN_in_joinedTable2866); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_JOIN.add(JOIN138);

                    pushFollow(FOLLOW_tableReference_in_joinedTable2868);
                    tableReference139=tableReference();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_tableReference.add(tableReference139.getTree());
                    ON140=(Token)match(input,ON,FOLLOW_ON_in_joinedTable2870); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ON.add(ON140);

                    pushFollow(FOLLOW_searchCondition_in_joinedTable2872);
                    searchCondition141=searchCondition();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_searchCondition.add(searchCondition141.getTree());


                    // AST REWRITE
                    // elements: searchCondition, searchCondition, tableReference, tableReference, tableReference, searchCondition, tableReference, tableReference, searchCondition, searchCondition, tableReference, tableReference, searchCondition, searchCondition
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 451:3: -> {inner != null}? ^( InnerJoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if (inner != null) {
                        // src/astudy/parser/sql/QTemplate.g:452:4: ^( InnerJoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(InnerJoinNode, "InnerJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:452:35: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 454:3: -> {exception != null && dir == null}? ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if (exception != null && dir == null) {
                        // src/astudy/parser/sql/QTemplate.g:455:4: ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RightExceptionJoinNode, "RightExceptionJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:455:44: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 456:3: -> {exception != null && \"left\".equalsIgnoreCase(dir.getText())}? ^( LeftExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if (exception != null && "left".equalsIgnoreCase(dir.getText())) {
                        // src/astudy/parser/sql/QTemplate.g:457:4: ^( LeftExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(LeftExceptionJoinNode, "LeftExceptionJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:457:43: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 458:3: -> {exception != null && \"right\".equalsIgnoreCase(dir.getText())}? ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if (exception != null && "right".equalsIgnoreCase(dir.getText())) {
                        // src/astudy/parser/sql/QTemplate.g:459:4: ^( RightExceptionJoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RightExceptionJoinNode, "RightExceptionJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:459:44: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 461:3: -> {dir == null}? ^( JoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if (dir == null) {
                        // src/astudy/parser/sql/QTemplate.g:462:4: ^( JoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(JoinNode, "JoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:462:30: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 463:3: -> {\"left\".equalsIgnoreCase(dir.getText())}? ^( LeftJoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if ("left".equalsIgnoreCase(dir.getText())) {
                        // src/astudy/parser/sql/QTemplate.g:464:4: ^( LeftJoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(LeftJoinNode, "LeftJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:464:34: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 465:3: -> {\"right\".equalsIgnoreCase(dir.getText())}? ^( RightJoinNode tableReference ^( ConditionsNode searchCondition ) )
                    if ("right".equalsIgnoreCase(dir.getText())) {
                        // src/astudy/parser/sql/QTemplate.g:466:4: ^( RightJoinNode tableReference ^( ConditionsNode searchCondition ) )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RightJoinNode, "RightJoinNode"), root_1);

                        adaptor.addChild(root_1, stream_tableReference.nextTree());
                        // src/astudy/parser/sql/QTemplate.g:466:35: ^( ConditionsNode searchCondition )
                        {
                        Object root_2 = (Object)adaptor.nil();
                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_2);

                        adaptor.addChild(root_2, stream_searchCondition.nextTree());

                        adaptor.addChild(root_1, root_2);
                        }

                        adaptor.addChild(root_0, root_1);
                        }

                    }
                    else // 468:3: ->
                    {
                        root_0 = null;
                    }

                    retval.tree = root_0;}
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "joinedTable"

    public static class correlationClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "correlationClause"
    // src/astudy/parser/sql/QTemplate.g:471:1: correlationClause : ( AS )? refid= identifier ( LPAREN columnName ( COMMA columnName )* RPAREN )? -> $refid;
    public final QTemplateParser.correlationClause_return correlationClause() throws RecognitionException {
        QTemplateParser.correlationClause_return retval = new QTemplateParser.correlationClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token AS142=null;
        Token LPAREN143=null;
        Token COMMA145=null;
        Token RPAREN147=null;
        QTemplateParser.identifier_return refid = null;

        QTemplateParser.columnName_return columnName144 = null;

        QTemplateParser.columnName_return columnName146 = null;


        Object AS142_tree=null;
        Object LPAREN143_tree=null;
        Object COMMA145_tree=null;
        Object RPAREN147_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_AS=new RewriteRuleTokenStream(adaptor,"token AS");
        RewriteRuleSubtreeStream stream_columnName=new RewriteRuleSubtreeStream(adaptor,"rule columnName");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        try {
            // src/astudy/parser/sql/QTemplate.g:472:2: ( ( AS )? refid= identifier ( LPAREN columnName ( COMMA columnName )* RPAREN )? -> $refid)
            // src/astudy/parser/sql/QTemplate.g:472:4: ( AS )? refid= identifier ( LPAREN columnName ( COMMA columnName )* RPAREN )?
            {
            // src/astudy/parser/sql/QTemplate.g:472:4: ( AS )?
            int alt54=2;
            int LA54_0 = input.LA(1);

            if ( (LA54_0==AS) ) {
                alt54=1;
            }
            switch (alt54) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:472:4: AS
                    {
                    AS142=(Token)match(input,AS,FOLLOW_AS_in_correlationClause3066); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_AS.add(AS142);


                    }
                    break;

            }

            pushFollow(FOLLOW_identifier_in_correlationClause3071);
            refid=identifier();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_identifier.add(refid.getTree());
            // src/astudy/parser/sql/QTemplate.g:473:3: ( LPAREN columnName ( COMMA columnName )* RPAREN )?
            int alt56=2;
            alt56 = dfa56.predict(input);
            switch (alt56) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:473:5: LPAREN columnName ( COMMA columnName )* RPAREN
                    {
                    LPAREN143=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_correlationClause3078); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN143);

                    pushFollow(FOLLOW_columnName_in_correlationClause3080);
                    columnName144=columnName();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_columnName.add(columnName144.getTree());
                    // src/astudy/parser/sql/QTemplate.g:473:23: ( COMMA columnName )*
                    loop55:
                    do {
                        int alt55=2;
                        int LA55_0 = input.LA(1);

                        if ( (LA55_0==COMMA) ) {
                            alt55=1;
                        }


                        switch (alt55) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:473:24: COMMA columnName
                    	    {
                    	    COMMA145=(Token)match(input,COMMA,FOLLOW_COMMA_in_correlationClause3083); if (state.failed) return retval; 
                    	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA145);

                    	    pushFollow(FOLLOW_columnName_in_correlationClause3085);
                    	    columnName146=columnName();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) stream_columnName.add(columnName146.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop55;
                        }
                    } while (true);

                    RPAREN147=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_correlationClause3089); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN147);


                    }
                    break;

            }



            // AST REWRITE
            // elements: refid
            // token labels: 
            // rule labels: retval, refid
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_refid=new RewriteRuleSubtreeStream(adaptor,"token refid",refid!=null?refid.tree:null);

            root_0 = (Object)adaptor.nil();
            // 474:3: -> $refid
            {
                adaptor.addChild(root_0, stream_refid.nextTree());

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "correlationClause"

    public static class whereClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "whereClause"
    // src/astudy/parser/sql/QTemplate.g:477:1: whereClause : WHERE searchCondition -> ^( ConditionsNode searchCondition ) ;
    public final QTemplateParser.whereClause_return whereClause() throws RecognitionException {
        QTemplateParser.whereClause_return retval = new QTemplateParser.whereClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token WHERE148=null;
        QTemplateParser.searchCondition_return searchCondition149 = null;


        Object WHERE148_tree=null;
        RewriteRuleTokenStream stream_WHERE=new RewriteRuleTokenStream(adaptor,"token WHERE");
        RewriteRuleSubtreeStream stream_searchCondition=new RewriteRuleSubtreeStream(adaptor,"rule searchCondition");
        try {
            // src/astudy/parser/sql/QTemplate.g:478:2: ( WHERE searchCondition -> ^( ConditionsNode searchCondition ) )
            // src/astudy/parser/sql/QTemplate.g:478:4: WHERE searchCondition
            {
            WHERE148=(Token)match(input,WHERE,FOLLOW_WHERE_in_whereClause3112); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_WHERE.add(WHERE148);

            pushFollow(FOLLOW_searchCondition_in_whereClause3114);
            searchCondition149=searchCondition();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_searchCondition.add(searchCondition149.getTree());


            // AST REWRITE
            // elements: searchCondition
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 479:3: -> ^( ConditionsNode searchCondition )
            {
                // src/astudy/parser/sql/QTemplate.g:479:6: ^( ConditionsNode searchCondition )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ConditionsNode, "ConditionsNode"), root_1);

                adaptor.addChild(root_1, stream_searchCondition.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "whereClause"

    public static class searchCondition_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "searchCondition"
    // src/astudy/parser/sql/QTemplate.g:482:1: searchCondition : subSearchCondition ( (op= AND | op= OR ) subSearchCondition )* -> ^( ExpressionNode subSearchCondition ) ( $op ^( ExpressionNode subSearchCondition ) )* ;
    public final QTemplateParser.searchCondition_return searchCondition() throws RecognitionException {
        QTemplateParser.searchCondition_return retval = new QTemplateParser.searchCondition_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token op=null;
        QTemplateParser.subSearchCondition_return subSearchCondition150 = null;

        QTemplateParser.subSearchCondition_return subSearchCondition151 = null;


        Object op_tree=null;
        RewriteRuleTokenStream stream_AND=new RewriteRuleTokenStream(adaptor,"token AND");
        RewriteRuleTokenStream stream_OR=new RewriteRuleTokenStream(adaptor,"token OR");
        RewriteRuleSubtreeStream stream_subSearchCondition=new RewriteRuleSubtreeStream(adaptor,"rule subSearchCondition");
        try {
            // src/astudy/parser/sql/QTemplate.g:483:2: ( subSearchCondition ( (op= AND | op= OR ) subSearchCondition )* -> ^( ExpressionNode subSearchCondition ) ( $op ^( ExpressionNode subSearchCondition ) )* )
            // src/astudy/parser/sql/QTemplate.g:483:4: subSearchCondition ( (op= AND | op= OR ) subSearchCondition )*
            {
            pushFollow(FOLLOW_subSearchCondition_in_searchCondition3136);
            subSearchCondition150=subSearchCondition();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_subSearchCondition.add(subSearchCondition150.getTree());
            // src/astudy/parser/sql/QTemplate.g:483:23: ( (op= AND | op= OR ) subSearchCondition )*
            loop58:
            do {
                int alt58=2;
                alt58 = dfa58.predict(input);
                switch (alt58) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:483:24: (op= AND | op= OR ) subSearchCondition
            	    {
            	    // src/astudy/parser/sql/QTemplate.g:483:24: (op= AND | op= OR )
            	    int alt57=2;
            	    int LA57_0 = input.LA(1);

            	    if ( (LA57_0==AND) ) {
            	        alt57=1;
            	    }
            	    else if ( (LA57_0==OR) ) {
            	        alt57=2;
            	    }
            	    else {
            	        if (state.backtracking>0) {state.failed=true; return retval;}
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 57, 0, input);

            	        throw nvae;
            	    }
            	    switch (alt57) {
            	        case 1 :
            	            // src/astudy/parser/sql/QTemplate.g:483:25: op= AND
            	            {
            	            op=(Token)match(input,AND,FOLLOW_AND_in_searchCondition3142); if (state.failed) return retval; 
            	            if ( state.backtracking==0 ) stream_AND.add(op);


            	            }
            	            break;
            	        case 2 :
            	            // src/astudy/parser/sql/QTemplate.g:483:32: op= OR
            	            {
            	            op=(Token)match(input,OR,FOLLOW_OR_in_searchCondition3146); if (state.failed) return retval; 
            	            if ( state.backtracking==0 ) stream_OR.add(op);


            	            }
            	            break;

            	    }

            	    pushFollow(FOLLOW_subSearchCondition_in_searchCondition3149);
            	    subSearchCondition151=subSearchCondition();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_subSearchCondition.add(subSearchCondition151.getTree());

            	    }
            	    break;

            	default :
            	    break loop58;
                }
            } while (true);



            // AST REWRITE
            // elements: subSearchCondition, subSearchCondition, op
            // token labels: op
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleTokenStream stream_op=new RewriteRuleTokenStream(adaptor,"token op",op);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 484:3: -> ^( ExpressionNode subSearchCondition ) ( $op ^( ExpressionNode subSearchCondition ) )*
            {
                // src/astudy/parser/sql/QTemplate.g:484:6: ^( ExpressionNode subSearchCondition )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ExpressionNode, "ExpressionNode"), root_1);

                adaptor.addChild(root_1, stream_subSearchCondition.nextTree());

                adaptor.addChild(root_0, root_1);
                }
                // src/astudy/parser/sql/QTemplate.g:484:43: ( $op ^( ExpressionNode subSearchCondition ) )*
                while ( stream_subSearchCondition.hasNext()||stream_op.hasNext() ) {
                    adaptor.addChild(root_0, stream_op.nextNode());
                    // src/astudy/parser/sql/QTemplate.g:484:48: ^( ExpressionNode subSearchCondition )
                    {
                    Object root_1 = (Object)adaptor.nil();
                    root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ExpressionNode, "ExpressionNode"), root_1);

                    adaptor.addChild(root_1, stream_subSearchCondition.nextTree());

                    adaptor.addChild(root_0, root_1);
                    }

                }
                stream_subSearchCondition.reset();
                stream_op.reset();

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "searchCondition"

    public static class subSearchCondition_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "subSearchCondition"
    // src/astudy/parser/sql/QTemplate.g:487:1: subSearchCondition : (not= NOT )? ( ( LPAREN searchCondition RPAREN )=> LPAREN searchCondition RPAREN | predicate ) -> ( $not)? ( searchCondition )? ( predicate )? ;
    public final QTemplateParser.subSearchCondition_return subSearchCondition() throws RecognitionException {
        QTemplateParser.subSearchCondition_return retval = new QTemplateParser.subSearchCondition_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token not=null;
        Token LPAREN152=null;
        Token RPAREN154=null;
        QTemplateParser.searchCondition_return searchCondition153 = null;

        QTemplateParser.predicate_return predicate155 = null;


        Object not_tree=null;
        Object LPAREN152_tree=null;
        Object RPAREN154_tree=null;
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_NOT=new RewriteRuleTokenStream(adaptor,"token NOT");
        RewriteRuleSubtreeStream stream_searchCondition=new RewriteRuleSubtreeStream(adaptor,"rule searchCondition");
        RewriteRuleSubtreeStream stream_predicate=new RewriteRuleSubtreeStream(adaptor,"rule predicate");
        try {
            // src/astudy/parser/sql/QTemplate.g:488:2: ( (not= NOT )? ( ( LPAREN searchCondition RPAREN )=> LPAREN searchCondition RPAREN | predicate ) -> ( $not)? ( searchCondition )? ( predicate )? )
            // src/astudy/parser/sql/QTemplate.g:488:4: (not= NOT )? ( ( LPAREN searchCondition RPAREN )=> LPAREN searchCondition RPAREN | predicate )
            {
            // src/astudy/parser/sql/QTemplate.g:488:7: (not= NOT )?
            int alt59=2;
            alt59 = dfa59.predict(input);
            switch (alt59) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:488:7: not= NOT
                    {
                    not=(Token)match(input,NOT,FOLLOW_NOT_in_subSearchCondition3187); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_NOT.add(not);


                    }
                    break;

            }

            // src/astudy/parser/sql/QTemplate.g:488:13: ( ( LPAREN searchCondition RPAREN )=> LPAREN searchCondition RPAREN | predicate )
            int alt60=2;
            alt60 = dfa60.predict(input);
            switch (alt60) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:489:4: ( LPAREN searchCondition RPAREN )=> LPAREN searchCondition RPAREN
                    {
                    LPAREN152=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_subSearchCondition3205); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN152);

                    pushFollow(FOLLOW_searchCondition_in_subSearchCondition3207);
                    searchCondition153=searchCondition();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_searchCondition.add(searchCondition153.getTree());
                    RPAREN154=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_subSearchCondition3209); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN154);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:490:6: predicate
                    {
                    pushFollow(FOLLOW_predicate_in_subSearchCondition3216);
                    predicate155=predicate();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_predicate.add(predicate155.getTree());

                    }
                    break;

            }



            // AST REWRITE
            // elements: not, predicate, searchCondition
            // token labels: not
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleTokenStream stream_not=new RewriteRuleTokenStream(adaptor,"token not",not);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 492:3: -> ( $not)? ( searchCondition )? ( predicate )?
            {
                // src/astudy/parser/sql/QTemplate.g:492:6: ( $not)?
                if ( stream_not.hasNext() ) {
                    adaptor.addChild(root_0, stream_not.nextNode());

                }
                stream_not.reset();
                // src/astudy/parser/sql/QTemplate.g:492:12: ( searchCondition )?
                if ( stream_searchCondition.hasNext() ) {
                    adaptor.addChild(root_0, stream_searchCondition.nextTree());

                }
                stream_searchCondition.reset();
                // src/astudy/parser/sql/QTemplate.g:492:29: ( predicate )?
                if ( stream_predicate.hasNext() ) {
                    adaptor.addChild(root_0, stream_predicate.nextTree());

                }
                stream_predicate.reset();

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subSearchCondition"

    public static class predicate_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "predicate"
    // src/astudy/parser/sql/QTemplate.g:494:1: predicate : ( EXISTS LPAREN subselect RPAREN -> ^( ExistsNode subselect ) | exp= expression (comp= compareOperator (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) ) | ( NOT )? ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) ) | IS ( NOT )? NULL -> ^( NotNullNode $exp) ) );
    public final QTemplateParser.predicate_return predicate() throws RecognitionException {
        QTemplateParser.predicate_return retval = new QTemplateParser.predicate_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token num=null;
        Token EXISTS156=null;
        Token LPAREN157=null;
        Token RPAREN159=null;
        Token LPAREN160=null;
        Token RPAREN162=null;
        Token NOT163=null;
        Token LIKE164=null;
        Token ESCAPE165=null;
        Token BETWEEN167=null;
        Token AND168=null;
        Token IN169=null;
        Token LPAREN170=null;
        Token COMMA172=null;
        Token RPAREN173=null;
        Token IS174=null;
        Token NOT175=null;
        Token NULL176=null;
        List list_i=null;
        QTemplateParser.expression_return exp = null;

        QTemplateParser.compareOperator_return comp = null;

        QTemplateParser.expression_return exp1 = null;

        QTemplateParser.expression_return exp2 = null;

        QTemplateParser.subselect_return subselect158 = null;

        QTemplateParser.subselect_return subselect161 = null;

        QTemplateParser.expression_return expression166 = null;

        QTemplateParser.subselect_return subselect171 = null;

        RuleReturnScope i = null;
        Object num_tree=null;
        Object EXISTS156_tree=null;
        Object LPAREN157_tree=null;
        Object RPAREN159_tree=null;
        Object LPAREN160_tree=null;
        Object RPAREN162_tree=null;
        Object NOT163_tree=null;
        Object LIKE164_tree=null;
        Object ESCAPE165_tree=null;
        Object BETWEEN167_tree=null;
        Object AND168_tree=null;
        Object IN169_tree=null;
        Object LPAREN170_tree=null;
        Object COMMA172_tree=null;
        Object RPAREN173_tree=null;
        Object IS174_tree=null;
        Object NOT175_tree=null;
        Object NULL176_tree=null;
        RewriteRuleTokenStream stream_EXISTS=new RewriteRuleTokenStream(adaptor,"token EXISTS");
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_SOME=new RewriteRuleTokenStream(adaptor,"token SOME");
        RewriteRuleTokenStream stream_AND=new RewriteRuleTokenStream(adaptor,"token AND");
        RewriteRuleTokenStream stream_IS=new RewriteRuleTokenStream(adaptor,"token IS");
        RewriteRuleTokenStream stream_NULL=new RewriteRuleTokenStream(adaptor,"token NULL");
        RewriteRuleTokenStream stream_ESCAPE=new RewriteRuleTokenStream(adaptor,"token ESCAPE");
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_BETWEEN=new RewriteRuleTokenStream(adaptor,"token BETWEEN");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_ALL=new RewriteRuleTokenStream(adaptor,"token ALL");
        RewriteRuleTokenStream stream_LIKE=new RewriteRuleTokenStream(adaptor,"token LIKE");
        RewriteRuleTokenStream stream_NOT=new RewriteRuleTokenStream(adaptor,"token NOT");
        RewriteRuleTokenStream stream_IN=new RewriteRuleTokenStream(adaptor,"token IN");
        RewriteRuleTokenStream stream_ANY=new RewriteRuleTokenStream(adaptor,"token ANY");
        RewriteRuleSubtreeStream stream_compareOperator=new RewriteRuleSubtreeStream(adaptor,"rule compareOperator");
        RewriteRuleSubtreeStream stream_subselect=new RewriteRuleSubtreeStream(adaptor,"rule subselect");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:499:2: ( EXISTS LPAREN subselect RPAREN -> ^( ExistsNode subselect ) | exp= expression (comp= compareOperator (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) ) | ( NOT )? ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) ) | IS ( NOT )? NULL -> ^( NotNullNode $exp) ) )
            int alt70=2;
            alt70 = dfa70.predict(input);
            switch (alt70) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:499:4: EXISTS LPAREN subselect RPAREN
                    {
                    EXISTS156=(Token)match(input,EXISTS,FOLLOW_EXISTS_in_predicate3247); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_EXISTS.add(EXISTS156);

                    LPAREN157=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_predicate3249); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN157);

                    pushFollow(FOLLOW_subselect_in_predicate3251);
                    subselect158=subselect();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_subselect.add(subselect158.getTree());
                    RPAREN159=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_predicate3253); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN159);



                    // AST REWRITE
                    // elements: subselect
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    if ( state.backtracking==0 ) {
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 500:3: -> ^( ExistsNode subselect )
                    {
                        // src/astudy/parser/sql/QTemplate.g:500:6: ^( ExistsNode subselect )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ExistsNode, "ExistsNode"), root_1);

                        adaptor.addChild(root_1, stream_subselect.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;}
                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:502:5: exp= expression (comp= compareOperator (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) ) | ( NOT )? ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) ) | IS ( NOT )? NULL -> ^( NotNullNode $exp) )
                    {
                    pushFollow(FOLLOW_expression_in_predicate3278);
                    exp=expression();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) stream_expression.add(exp.getTree());
                    // src/astudy/parser/sql/QTemplate.g:502:21: (comp= compareOperator (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) ) | ( NOT )? ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) ) | IS ( NOT )? NULL -> ^( NotNullNode $exp) )
                    int alt69=3;
                    switch ( input.LA(1) ) {
                    case EQ:
                    case NE:
                    case LE:
                    case GT:
                    case NL:
                    case NG:
                        {
                        alt69=1;
                        }
                        break;
                    case NOT:
                    case BETWEEN:
                    case IN:
                    case LIKE:
                        {
                        alt69=2;
                        }
                        break;
                    case IS:
                        {
                        alt69=3;
                        }
                        break;
                    default:
                        if (state.backtracking>0) {state.failed=true; return retval;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 69, 0, input);

                        throw nvae;
                    }

                    switch (alt69) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:503:4: comp= compareOperator (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) )
                            {
                            pushFollow(FOLLOW_compareOperator_in_predicate3288);
                            comp=compareOperator();

                            state._fsp--;
                            if (state.failed) return retval;
                            if ( state.backtracking==0 ) stream_compareOperator.add(comp.getTree());
                            // src/astudy/parser/sql/QTemplate.g:503:26: (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) )
                            int alt62=2;
                            alt62 = dfa62.predict(input);
                            switch (alt62) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:504:5: exp1= expression
                                    {
                                    pushFollow(FOLLOW_expression_in_predicate3299);
                                    exp1=expression();

                                    state._fsp--;
                                    if (state.failed) return retval;
                                    if ( state.backtracking==0 ) stream_expression.add(exp1.getTree());


                                    // AST REWRITE
                                    // elements: comp, exp1, exp
                                    // token labels: 
                                    // rule labels: exp, retval, exp1, comp
                                    // token list labels: 
                                    // rule list labels: 
                                    if ( state.backtracking==0 ) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
                                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
                                    RewriteRuleSubtreeStream stream_exp1=new RewriteRuleSubtreeStream(adaptor,"token exp1",exp1!=null?exp1.tree:null);
                                    RewriteRuleSubtreeStream stream_comp=new RewriteRuleSubtreeStream(adaptor,"token comp",comp!=null?comp.tree:null);

                                    root_0 = (Object)adaptor.nil();
                                    // 505:5: -> ^( CompareNode $comp $exp $exp1)
                                    {
                                        // src/astudy/parser/sql/QTemplate.g:505:8: ^( CompareNode $comp $exp $exp1)
                                        {
                                        Object root_1 = (Object)adaptor.nil();
                                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CompareNode, "CompareNode"), root_1);

                                        adaptor.addChild(root_1, stream_comp.nextTree());
                                        adaptor.addChild(root_1, stream_exp.nextTree());
                                        adaptor.addChild(root_1, stream_exp1.nextTree());

                                        adaptor.addChild(root_0, root_1);
                                        }

                                    }

                                    retval.tree = root_0;}
                                    }
                                    break;
                                case 2 :
                                    // src/astudy/parser/sql/QTemplate.g:506:7: (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN
                                    {
                                    // src/astudy/parser/sql/QTemplate.g:506:7: (num= SOME | num= ALL | num= ANY )
                                    int alt61=3;
                                    switch ( input.LA(1) ) {
                                    case SOME:
                                        {
                                        alt61=1;
                                        }
                                        break;
                                    case ALL:
                                        {
                                        alt61=2;
                                        }
                                        break;
                                    case ANY:
                                        {
                                        alt61=3;
                                        }
                                        break;
                                    default:
                                        if (state.backtracking>0) {state.failed=true; return retval;}
                                        NoViableAltException nvae =
                                            new NoViableAltException("", 61, 0, input);

                                        throw nvae;
                                    }

                                    switch (alt61) {
                                        case 1 :
                                            // src/astudy/parser/sql/QTemplate.g:506:8: num= SOME
                                            {
                                            num=(Token)match(input,SOME,FOLLOW_SOME_in_predicate3331); if (state.failed) return retval; 
                                            if ( state.backtracking==0 ) stream_SOME.add(num);


                                            }
                                            break;
                                        case 2 :
                                            // src/astudy/parser/sql/QTemplate.g:506:17: num= ALL
                                            {
                                            num=(Token)match(input,ALL,FOLLOW_ALL_in_predicate3335); if (state.failed) return retval; 
                                            if ( state.backtracking==0 ) stream_ALL.add(num);


                                            }
                                            break;
                                        case 3 :
                                            // src/astudy/parser/sql/QTemplate.g:506:25: num= ANY
                                            {
                                            num=(Token)match(input,ANY,FOLLOW_ANY_in_predicate3339); if (state.failed) return retval; 
                                            if ( state.backtracking==0 ) stream_ANY.add(num);


                                            }
                                            break;

                                    }

                                    LPAREN160=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_predicate3342); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN160);

                                    pushFollow(FOLLOW_subselect_in_predicate3344);
                                    subselect161=subselect();

                                    state._fsp--;
                                    if (state.failed) return retval;
                                    if ( state.backtracking==0 ) stream_subselect.add(subselect161.getTree());
                                    RPAREN162=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_predicate3346); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN162);



                                    // AST REWRITE
                                    // elements: comp, subselect, exp, num
                                    // token labels: num
                                    // rule labels: exp, retval, comp
                                    // token list labels: 
                                    // rule list labels: 
                                    if ( state.backtracking==0 ) {
                                    retval.tree = root_0;
                                    RewriteRuleTokenStream stream_num=new RewriteRuleTokenStream(adaptor,"token num",num);
                                    RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
                                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
                                    RewriteRuleSubtreeStream stream_comp=new RewriteRuleSubtreeStream(adaptor,"token comp",comp!=null?comp.tree:null);

                                    root_0 = (Object)adaptor.nil();
                                    // 507:5: -> ^( CompareNode $comp $exp $num subselect )
                                    {
                                        // src/astudy/parser/sql/QTemplate.g:507:8: ^( CompareNode $comp $exp $num subselect )
                                        {
                                        Object root_1 = (Object)adaptor.nil();
                                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CompareNode, "CompareNode"), root_1);

                                        adaptor.addChild(root_1, stream_comp.nextTree());
                                        adaptor.addChild(root_1, stream_exp.nextTree());
                                        adaptor.addChild(root_1, stream_num.nextNode());
                                        adaptor.addChild(root_1, stream_subselect.nextTree());

                                        adaptor.addChild(root_0, root_1);
                                        }

                                    }

                                    retval.tree = root_0;}
                                    }
                                    break;

                            }


                            }
                            break;
                        case 2 :
                            // src/astudy/parser/sql/QTemplate.g:509:6: ( NOT )? ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) )
                            {
                            // src/astudy/parser/sql/QTemplate.g:509:6: ( NOT )?
                            int alt63=2;
                            int LA63_0 = input.LA(1);

                            if ( (LA63_0==NOT) ) {
                                alt63=1;
                            }
                            switch (alt63) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:509:6: NOT
                                    {
                                    NOT163=(Token)match(input,NOT,FOLLOW_NOT_in_predicate3380); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_NOT.add(NOT163);


                                    }
                                    break;

                            }

                            // src/astudy/parser/sql/QTemplate.g:509:11: ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) )
                            int alt67=3;
                            switch ( input.LA(1) ) {
                            case LIKE:
                                {
                                alt67=1;
                                }
                                break;
                            case BETWEEN:
                                {
                                alt67=2;
                                }
                                break;
                            case IN:
                                {
                                alt67=3;
                                }
                                break;
                            default:
                                if (state.backtracking>0) {state.failed=true; return retval;}
                                NoViableAltException nvae =
                                    new NoViableAltException("", 67, 0, input);

                                throw nvae;
                            }

                            switch (alt67) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:510:5: LIKE exp1= expression ( ESCAPE expression )?
                                    {
                                    LIKE164=(Token)match(input,LIKE,FOLLOW_LIKE_in_predicate3389); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_LIKE.add(LIKE164);

                                    pushFollow(FOLLOW_expression_in_predicate3393);
                                    exp1=expression();

                                    state._fsp--;
                                    if (state.failed) return retval;
                                    if ( state.backtracking==0 ) stream_expression.add(exp1.getTree());
                                    // src/astudy/parser/sql/QTemplate.g:510:26: ( ESCAPE expression )?
                                    int alt64=2;
                                    alt64 = dfa64.predict(input);
                                    switch (alt64) {
                                        case 1 :
                                            // src/astudy/parser/sql/QTemplate.g:510:27: ESCAPE expression
                                            {
                                            ESCAPE165=(Token)match(input,ESCAPE,FOLLOW_ESCAPE_in_predicate3396); if (state.failed) return retval; 
                                            if ( state.backtracking==0 ) stream_ESCAPE.add(ESCAPE165);

                                            pushFollow(FOLLOW_expression_in_predicate3398);
                                            expression166=expression();

                                            state._fsp--;
                                            if (state.failed) return retval;
                                            if ( state.backtracking==0 ) stream_expression.add(expression166.getTree());

                                            }
                                            break;

                                    }



                                    // AST REWRITE
                                    // elements: exp1, exp, LIKE
                                    // token labels: 
                                    // rule labels: exp, retval, exp1
                                    // token list labels: 
                                    // rule list labels: 
                                    if ( state.backtracking==0 ) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
                                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
                                    RewriteRuleSubtreeStream stream_exp1=new RewriteRuleSubtreeStream(adaptor,"token exp1",exp1!=null?exp1.tree:null);

                                    root_0 = (Object)adaptor.nil();
                                    // 511:5: -> ^( LIKE $exp $exp1)
                                    {
                                        // src/astudy/parser/sql/QTemplate.g:511:8: ^( LIKE $exp $exp1)
                                        {
                                        Object root_1 = (Object)adaptor.nil();
                                        root_1 = (Object)adaptor.becomeRoot(stream_LIKE.nextNode(), root_1);

                                        adaptor.addChild(root_1, stream_exp.nextTree());
                                        adaptor.addChild(root_1, stream_exp1.nextTree());

                                        adaptor.addChild(root_0, root_1);
                                        }

                                    }

                                    retval.tree = root_0;}
                                    }
                                    break;
                                case 2 :
                                    // src/astudy/parser/sql/QTemplate.g:512:7: BETWEEN exp1= expression AND exp2= expression
                                    {
                                    BETWEEN167=(Token)match(input,BETWEEN,FOLLOW_BETWEEN_in_predicate3425); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_BETWEEN.add(BETWEEN167);

                                    pushFollow(FOLLOW_expression_in_predicate3429);
                                    exp1=expression();

                                    state._fsp--;
                                    if (state.failed) return retval;
                                    if ( state.backtracking==0 ) stream_expression.add(exp1.getTree());
                                    AND168=(Token)match(input,AND,FOLLOW_AND_in_predicate3431); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_AND.add(AND168);

                                    pushFollow(FOLLOW_expression_in_predicate3435);
                                    exp2=expression();

                                    state._fsp--;
                                    if (state.failed) return retval;
                                    if ( state.backtracking==0 ) stream_expression.add(exp2.getTree());


                                    // AST REWRITE
                                    // elements: exp2, BETWEEN, exp1, exp
                                    // token labels: 
                                    // rule labels: exp, exp2, retval, exp1
                                    // token list labels: 
                                    // rule list labels: 
                                    if ( state.backtracking==0 ) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
                                    RewriteRuleSubtreeStream stream_exp2=new RewriteRuleSubtreeStream(adaptor,"token exp2",exp2!=null?exp2.tree:null);
                                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
                                    RewriteRuleSubtreeStream stream_exp1=new RewriteRuleSubtreeStream(adaptor,"token exp1",exp1!=null?exp1.tree:null);

                                    root_0 = (Object)adaptor.nil();
                                    // 513:5: -> ^( BETWEEN $exp $exp1 $exp2)
                                    {
                                        // src/astudy/parser/sql/QTemplate.g:513:8: ^( BETWEEN $exp $exp1 $exp2)
                                        {
                                        Object root_1 = (Object)adaptor.nil();
                                        root_1 = (Object)adaptor.becomeRoot(stream_BETWEEN.nextNode(), root_1);

                                        adaptor.addChild(root_1, stream_exp.nextTree());
                                        adaptor.addChild(root_1, stream_exp1.nextTree());
                                        adaptor.addChild(root_1, stream_exp2.nextTree());

                                        adaptor.addChild(root_0, root_1);
                                        }

                                    }

                                    retval.tree = root_0;}
                                    }
                                    break;
                                case 3 :
                                    // src/astudy/parser/sql/QTemplate.g:514:7: IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN
                                    {
                                    IN169=(Token)match(input,IN,FOLLOW_IN_in_predicate3464); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_IN.add(IN169);

                                    LPAREN170=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_predicate3467); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_LPAREN.add(LPAREN170);

                                    // src/astudy/parser/sql/QTemplate.g:514:18: ( subselect | i+= expression ( COMMA i+= expression )* )
                                    int alt66=2;
                                    alt66 = dfa66.predict(input);
                                    switch (alt66) {
                                        case 1 :
                                            // src/astudy/parser/sql/QTemplate.g:515:6: subselect
                                            {
                                            pushFollow(FOLLOW_subselect_in_predicate3476);
                                            subselect171=subselect();

                                            state._fsp--;
                                            if (state.failed) return retval;
                                            if ( state.backtracking==0 ) stream_subselect.add(subselect171.getTree());

                                            }
                                            break;
                                        case 2 :
                                            // src/astudy/parser/sql/QTemplate.g:515:18: i+= expression ( COMMA i+= expression )*
                                            {
                                            pushFollow(FOLLOW_expression_in_predicate3482);
                                            i=expression();

                                            state._fsp--;
                                            if (state.failed) return retval;
                                            if ( state.backtracking==0 ) stream_expression.add(i.getTree());
                                            if (list_i==null) list_i=new ArrayList();
                                            list_i.add(i.getTree());

                                            // src/astudy/parser/sql/QTemplate.g:515:32: ( COMMA i+= expression )*
                                            loop65:
                                            do {
                                                int alt65=2;
                                                int LA65_0 = input.LA(1);

                                                if ( (LA65_0==COMMA) ) {
                                                    alt65=1;
                                                }


                                                switch (alt65) {
                                            	case 1 :
                                            	    // src/astudy/parser/sql/QTemplate.g:515:33: COMMA i+= expression
                                            	    {
                                            	    COMMA172=(Token)match(input,COMMA,FOLLOW_COMMA_in_predicate3485); if (state.failed) return retval; 
                                            	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA172);

                                            	    pushFollow(FOLLOW_expression_in_predicate3489);
                                            	    i=expression();

                                            	    state._fsp--;
                                            	    if (state.failed) return retval;
                                            	    if ( state.backtracking==0 ) stream_expression.add(i.getTree());
                                            	    if (list_i==null) list_i=new ArrayList();
                                            	    list_i.add(i.getTree());


                                            	    }
                                            	    break;

                                            	default :
                                            	    break loop65;
                                                }
                                            } while (true);


                                            }
                                            break;

                                    }

                                    RPAREN173=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_predicate3500); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_RPAREN.add(RPAREN173);



                                    // AST REWRITE
                                    // elements: exp, IN, i, exp, IN, subselect
                                    // token labels: 
                                    // rule labels: exp, retval
                                    // token list labels: 
                                    // rule list labels: i
                                    if ( state.backtracking==0 ) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
                                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
                                    RewriteRuleSubtreeStream stream_i=new RewriteRuleSubtreeStream(adaptor,"token i",list_i);
                                    root_0 = (Object)adaptor.nil();
                                    // 517:5: -> {$i == null}? ^( IN $exp subselect )
                                    if (list_i == null) {
                                        // src/astudy/parser/sql/QTemplate.g:517:22: ^( IN $exp subselect )
                                        {
                                        Object root_1 = (Object)adaptor.nil();
                                        root_1 = (Object)adaptor.becomeRoot(stream_IN.nextNode(), root_1);

                                        adaptor.addChild(root_1, stream_exp.nextTree());
                                        adaptor.addChild(root_1, stream_subselect.nextTree());

                                        adaptor.addChild(root_0, root_1);
                                        }

                                    }
                                    else // 518:5: -> ^( IN $exp ^( ArrayNode ( $i)* ) )
                                    {
                                        // src/astudy/parser/sql/QTemplate.g:518:22: ^( IN $exp ^( ArrayNode ( $i)* ) )
                                        {
                                        Object root_1 = (Object)adaptor.nil();
                                        root_1 = (Object)adaptor.becomeRoot(stream_IN.nextNode(), root_1);

                                        adaptor.addChild(root_1, stream_exp.nextTree());
                                        // src/astudy/parser/sql/QTemplate.g:518:32: ^( ArrayNode ( $i)* )
                                        {
                                        Object root_2 = (Object)adaptor.nil();
                                        root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ArrayNode, "ArrayNode"), root_2);

                                        // src/astudy/parser/sql/QTemplate.g:518:44: ( $i)*
                                        while ( stream_i.hasNext() ) {
                                            adaptor.addChild(root_2, stream_i.nextTree());

                                        }
                                        stream_i.reset();

                                        adaptor.addChild(root_1, root_2);
                                        }

                                        adaptor.addChild(root_0, root_1);
                                        }

                                    }

                                    retval.tree = root_0;}
                                    }
                                    break;

                            }


                            }
                            break;
                        case 3 :
                            // src/astudy/parser/sql/QTemplate.g:520:6: IS ( NOT )? NULL
                            {
                            IS174=(Token)match(input,IS,FOLLOW_IS_in_predicate3566); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_IS.add(IS174);

                            // src/astudy/parser/sql/QTemplate.g:520:9: ( NOT )?
                            int alt68=2;
                            int LA68_0 = input.LA(1);

                            if ( (LA68_0==NOT) ) {
                                alt68=1;
                            }
                            switch (alt68) {
                                case 1 :
                                    // src/astudy/parser/sql/QTemplate.g:520:9: NOT
                                    {
                                    NOT175=(Token)match(input,NOT,FOLLOW_NOT_in_predicate3568); if (state.failed) return retval; 
                                    if ( state.backtracking==0 ) stream_NOT.add(NOT175);


                                    }
                                    break;

                            }

                            NULL176=(Token)match(input,NULL,FOLLOW_NULL_in_predicate3571); if (state.failed) return retval; 
                            if ( state.backtracking==0 ) stream_NULL.add(NULL176);



                            // AST REWRITE
                            // elements: exp
                            // token labels: 
                            // rule labels: exp, retval
                            // token list labels: 
                            // rule list labels: 
                            if ( state.backtracking==0 ) {
                            retval.tree = root_0;
                            RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"token exp",exp!=null?exp.tree:null);
                            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

                            root_0 = (Object)adaptor.nil();
                            // 521:4: -> ^( NotNullNode $exp)
                            {
                                // src/astudy/parser/sql/QTemplate.g:521:7: ^( NotNullNode $exp)
                                {
                                Object root_1 = (Object)adaptor.nil();
                                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(NotNullNode, "NotNullNode"), root_1);

                                adaptor.addChild(root_1, stream_exp.nextTree());

                                adaptor.addChild(root_0, root_1);
                                }

                            }

                            retval.tree = root_0;}
                            }
                            break;

                    }


                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "predicate"

    public static class groupByClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "groupByClause"
    // src/astudy/parser/sql/QTemplate.g:525:1: groupByClause : GROUP BY groupingExpression -> ^( GroupByNode groupingExpression ) ;
    public final QTemplateParser.groupByClause_return groupByClause() throws RecognitionException {
        QTemplateParser.groupByClause_return retval = new QTemplateParser.groupByClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token GROUP177=null;
        Token BY178=null;
        QTemplateParser.groupingExpression_return groupingExpression179 = null;


        Object GROUP177_tree=null;
        Object BY178_tree=null;
        RewriteRuleTokenStream stream_BY=new RewriteRuleTokenStream(adaptor,"token BY");
        RewriteRuleTokenStream stream_GROUP=new RewriteRuleTokenStream(adaptor,"token GROUP");
        RewriteRuleSubtreeStream stream_groupingExpression=new RewriteRuleSubtreeStream(adaptor,"rule groupingExpression");
        try {
            // src/astudy/parser/sql/QTemplate.g:526:2: ( GROUP BY groupingExpression -> ^( GroupByNode groupingExpression ) )
            // src/astudy/parser/sql/QTemplate.g:526:4: GROUP BY groupingExpression
            {
            GROUP177=(Token)match(input,GROUP,FOLLOW_GROUP_in_groupByClause3604); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_GROUP.add(GROUP177);

            BY178=(Token)match(input,BY,FOLLOW_BY_in_groupByClause3606); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_BY.add(BY178);

            pushFollow(FOLLOW_groupingExpression_in_groupByClause3608);
            groupingExpression179=groupingExpression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_groupingExpression.add(groupingExpression179.getTree());


            // AST REWRITE
            // elements: groupingExpression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 527:3: -> ^( GroupByNode groupingExpression )
            {
                // src/astudy/parser/sql/QTemplate.g:527:6: ^( GroupByNode groupingExpression )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(GroupByNode, "GroupByNode"), root_1);

                adaptor.addChild(root_1, stream_groupingExpression.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "groupByClause"

    public static class groupingExpression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "groupingExpression"
    // src/astudy/parser/sql/QTemplate.g:530:1: groupingExpression : expression ( COMMA expression )* -> ^( ExpressionsNode ( ^( ExpressionNode expression ) )* ) ;
    public final QTemplateParser.groupingExpression_return groupingExpression() throws RecognitionException {
        QTemplateParser.groupingExpression_return retval = new QTemplateParser.groupingExpression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token COMMA181=null;
        QTemplateParser.expression_return expression180 = null;

        QTemplateParser.expression_return expression182 = null;


        Object COMMA181_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // src/astudy/parser/sql/QTemplate.g:531:2: ( expression ( COMMA expression )* -> ^( ExpressionsNode ( ^( ExpressionNode expression ) )* ) )
            // src/astudy/parser/sql/QTemplate.g:531:4: expression ( COMMA expression )*
            {
            pushFollow(FOLLOW_expression_in_groupingExpression3630);
            expression180=expression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_expression.add(expression180.getTree());
            // src/astudy/parser/sql/QTemplate.g:531:15: ( COMMA expression )*
            loop71:
            do {
                int alt71=2;
                alt71 = dfa71.predict(input);
                switch (alt71) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:531:16: COMMA expression
            	    {
            	    COMMA181=(Token)match(input,COMMA,FOLLOW_COMMA_in_groupingExpression3633); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA181);

            	    pushFollow(FOLLOW_expression_in_groupingExpression3635);
            	    expression182=expression();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_expression.add(expression182.getTree());

            	    }
            	    break;

            	default :
            	    break loop71;
                }
            } while (true);



            // AST REWRITE
            // elements: expression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 532:3: -> ^( ExpressionsNode ( ^( ExpressionNode expression ) )* )
            {
                // src/astudy/parser/sql/QTemplate.g:532:6: ^( ExpressionsNode ( ^( ExpressionNode expression ) )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ExpressionsNode, "ExpressionsNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:532:24: ( ^( ExpressionNode expression ) )*
                while ( stream_expression.hasNext() ) {
                    // src/astudy/parser/sql/QTemplate.g:532:24: ^( ExpressionNode expression )
                    {
                    Object root_2 = (Object)adaptor.nil();
                    root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ExpressionNode, "ExpressionNode"), root_2);

                    adaptor.addChild(root_2, stream_expression.nextTree());

                    adaptor.addChild(root_1, root_2);
                    }

                }
                stream_expression.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "groupingExpression"

    public static class havingClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "havingClause"
    // src/astudy/parser/sql/QTemplate.g:535:1: havingClause : HAVING searchCondition -> ^( HavingNode searchCondition ) ;
    public final QTemplateParser.havingClause_return havingClause() throws RecognitionException {
        QTemplateParser.havingClause_return retval = new QTemplateParser.havingClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token HAVING183=null;
        QTemplateParser.searchCondition_return searchCondition184 = null;


        Object HAVING183_tree=null;
        RewriteRuleTokenStream stream_HAVING=new RewriteRuleTokenStream(adaptor,"token HAVING");
        RewriteRuleSubtreeStream stream_searchCondition=new RewriteRuleSubtreeStream(adaptor,"rule searchCondition");
        try {
            // src/astudy/parser/sql/QTemplate.g:536:2: ( HAVING searchCondition -> ^( HavingNode searchCondition ) )
            // src/astudy/parser/sql/QTemplate.g:536:4: HAVING searchCondition
            {
            HAVING183=(Token)match(input,HAVING,FOLLOW_HAVING_in_havingClause3664); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_HAVING.add(HAVING183);

            pushFollow(FOLLOW_searchCondition_in_havingClause3666);
            searchCondition184=searchCondition();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_searchCondition.add(searchCondition184.getTree());


            // AST REWRITE
            // elements: searchCondition
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 537:3: -> ^( HavingNode searchCondition )
            {
                // src/astudy/parser/sql/QTemplate.g:537:6: ^( HavingNode searchCondition )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(HavingNode, "HavingNode"), root_1);

                adaptor.addChild(root_1, stream_searchCondition.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "havingClause"

    public static class orderByClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "orderByClause"
    // src/astudy/parser/sql/QTemplate.g:540:1: orderByClause : ORDER BY subOrder ( COMMA subOrder )* -> ^( OrdersNode ( subOrder )* ) ;
    public final QTemplateParser.orderByClause_return orderByClause() throws RecognitionException {
        QTemplateParser.orderByClause_return retval = new QTemplateParser.orderByClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token ORDER185=null;
        Token BY186=null;
        Token COMMA188=null;
        QTemplateParser.subOrder_return subOrder187 = null;

        QTemplateParser.subOrder_return subOrder189 = null;


        Object ORDER185_tree=null;
        Object BY186_tree=null;
        Object COMMA188_tree=null;
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_ORDER=new RewriteRuleTokenStream(adaptor,"token ORDER");
        RewriteRuleTokenStream stream_BY=new RewriteRuleTokenStream(adaptor,"token BY");
        RewriteRuleSubtreeStream stream_subOrder=new RewriteRuleSubtreeStream(adaptor,"rule subOrder");
        try {
            // src/astudy/parser/sql/QTemplate.g:541:2: ( ORDER BY subOrder ( COMMA subOrder )* -> ^( OrdersNode ( subOrder )* ) )
            // src/astudy/parser/sql/QTemplate.g:541:4: ORDER BY subOrder ( COMMA subOrder )*
            {
            ORDER185=(Token)match(input,ORDER,FOLLOW_ORDER_in_orderByClause3688); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_ORDER.add(ORDER185);

            BY186=(Token)match(input,BY,FOLLOW_BY_in_orderByClause3690); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_BY.add(BY186);

            pushFollow(FOLLOW_subOrder_in_orderByClause3692);
            subOrder187=subOrder();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_subOrder.add(subOrder187.getTree());
            // src/astudy/parser/sql/QTemplate.g:541:22: ( COMMA subOrder )*
            loop72:
            do {
                int alt72=2;
                int LA72_0 = input.LA(1);

                if ( (LA72_0==COMMA) ) {
                    alt72=1;
                }


                switch (alt72) {
            	case 1 :
            	    // src/astudy/parser/sql/QTemplate.g:541:23: COMMA subOrder
            	    {
            	    COMMA188=(Token)match(input,COMMA,FOLLOW_COMMA_in_orderByClause3695); if (state.failed) return retval; 
            	    if ( state.backtracking==0 ) stream_COMMA.add(COMMA188);

            	    pushFollow(FOLLOW_subOrder_in_orderByClause3697);
            	    subOrder189=subOrder();

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) stream_subOrder.add(subOrder189.getTree());

            	    }
            	    break;

            	default :
            	    break loop72;
                }
            } while (true);



            // AST REWRITE
            // elements: subOrder
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 542:3: -> ^( OrdersNode ( subOrder )* )
            {
                // src/astudy/parser/sql/QTemplate.g:542:6: ^( OrdersNode ( subOrder )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(OrdersNode, "OrdersNode"), root_1);

                // src/astudy/parser/sql/QTemplate.g:542:19: ( subOrder )*
                while ( stream_subOrder.hasNext() ) {
                    adaptor.addChild(root_1, stream_subOrder.nextTree());

                }
                stream_subOrder.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "orderByClause"

    public static class subOrder_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "subOrder"
    // src/astudy/parser/sql/QTemplate.g:545:1: subOrder : sortKey (order= ASC | order= DESC )? -> ^( OrderNode sortKey ( $order)? ) ;
    public final QTemplateParser.subOrder_return subOrder() throws RecognitionException {
        QTemplateParser.subOrder_return retval = new QTemplateParser.subOrder_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token order=null;
        QTemplateParser.sortKey_return sortKey190 = null;


        Object order_tree=null;
        RewriteRuleTokenStream stream_DESC=new RewriteRuleTokenStream(adaptor,"token DESC");
        RewriteRuleTokenStream stream_ASC=new RewriteRuleTokenStream(adaptor,"token ASC");
        RewriteRuleSubtreeStream stream_sortKey=new RewriteRuleSubtreeStream(adaptor,"rule sortKey");
        try {
            // src/astudy/parser/sql/QTemplate.g:546:2: ( sortKey (order= ASC | order= DESC )? -> ^( OrderNode sortKey ( $order)? ) )
            // src/astudy/parser/sql/QTemplate.g:546:4: sortKey (order= ASC | order= DESC )?
            {
            pushFollow(FOLLOW_sortKey_in_subOrder3721);
            sortKey190=sortKey();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) stream_sortKey.add(sortKey190.getTree());
            // src/astudy/parser/sql/QTemplate.g:546:12: (order= ASC | order= DESC )?
            int alt73=3;
            alt73 = dfa73.predict(input);
            switch (alt73) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:546:13: order= ASC
                    {
                    order=(Token)match(input,ASC,FOLLOW_ASC_in_subOrder3726); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ASC.add(order);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:546:23: order= DESC
                    {
                    order=(Token)match(input,DESC,FOLLOW_DESC_in_subOrder3730); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_DESC.add(order);


                    }
                    break;

            }



            // AST REWRITE
            // elements: order, sortKey
            // token labels: order
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleTokenStream stream_order=new RewriteRuleTokenStream(adaptor,"token order",order);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 547:3: -> ^( OrderNode sortKey ( $order)? )
            {
                // src/astudy/parser/sql/QTemplate.g:547:6: ^( OrderNode sortKey ( $order)? )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(OrderNode, "OrderNode"), root_1);

                adaptor.addChild(root_1, stream_sortKey.nextTree());
                // src/astudy/parser/sql/QTemplate.g:547:26: ( $order)?
                if ( stream_order.hasNext() ) {
                    adaptor.addChild(root_1, stream_order.nextNode());

                }
                stream_order.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subOrder"

    public static class sortKey_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "sortKey"
    // src/astudy/parser/sql/QTemplate.g:550:1: sortKey : expression ;
    public final QTemplateParser.sortKey_return sortKey() throws RecognitionException {
        QTemplateParser.sortKey_return retval = new QTemplateParser.sortKey_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        QTemplateParser.expression_return expression191 = null;



        try {
            // src/astudy/parser/sql/QTemplate.g:551:2: ( expression )
            // src/astudy/parser/sql/QTemplate.g:551:4: expression
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_expression_in_sortKey3759);
            expression191=expression();

            state._fsp--;
            if (state.failed) return retval;
            if ( state.backtracking==0 ) adaptor.addChild(root_0, expression191.getTree());

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "sortKey"

    public static class fetchFirstClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "fetchFirstClause"
    // src/astudy/parser/sql/QTemplate.g:555:1: fetchFirstClause : FETCH FIRST (rows= INTEGER ) ( ROW | ROWS ) ONLY -> ^( PaginationNode $rows) ;
    public final QTemplateParser.fetchFirstClause_return fetchFirstClause() throws RecognitionException {
        QTemplateParser.fetchFirstClause_return retval = new QTemplateParser.fetchFirstClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token rows=null;
        Token FETCH192=null;
        Token FIRST193=null;
        Token ROW194=null;
        Token ROWS195=null;
        Token ONLY196=null;

        Object rows_tree=null;
        Object FETCH192_tree=null;
        Object FIRST193_tree=null;
        Object ROW194_tree=null;
        Object ROWS195_tree=null;
        Object ONLY196_tree=null;
        RewriteRuleTokenStream stream_FETCH=new RewriteRuleTokenStream(adaptor,"token FETCH");
        RewriteRuleTokenStream stream_INTEGER=new RewriteRuleTokenStream(adaptor,"token INTEGER");
        RewriteRuleTokenStream stream_ROWS=new RewriteRuleTokenStream(adaptor,"token ROWS");
        RewriteRuleTokenStream stream_FIRST=new RewriteRuleTokenStream(adaptor,"token FIRST");
        RewriteRuleTokenStream stream_ONLY=new RewriteRuleTokenStream(adaptor,"token ONLY");
        RewriteRuleTokenStream stream_ROW=new RewriteRuleTokenStream(adaptor,"token ROW");

        try {
            // src/astudy/parser/sql/QTemplate.g:556:2: ( FETCH FIRST (rows= INTEGER ) ( ROW | ROWS ) ONLY -> ^( PaginationNode $rows) )
            // src/astudy/parser/sql/QTemplate.g:556:4: FETCH FIRST (rows= INTEGER ) ( ROW | ROWS ) ONLY
            {
            FETCH192=(Token)match(input,FETCH,FOLLOW_FETCH_in_fetchFirstClause3772); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_FETCH.add(FETCH192);

            FIRST193=(Token)match(input,FIRST,FOLLOW_FIRST_in_fetchFirstClause3774); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_FIRST.add(FIRST193);

            // src/astudy/parser/sql/QTemplate.g:556:16: (rows= INTEGER )
            // src/astudy/parser/sql/QTemplate.g:556:17: rows= INTEGER
            {
            rows=(Token)match(input,INTEGER,FOLLOW_INTEGER_in_fetchFirstClause3779); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_INTEGER.add(rows);


            }

            // src/astudy/parser/sql/QTemplate.g:556:32: ( ROW | ROWS )
            int alt74=2;
            int LA74_0 = input.LA(1);

            if ( (LA74_0==ROW) ) {
                alt74=1;
            }
            else if ( (LA74_0==ROWS) ) {
                alt74=2;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 74, 0, input);

                throw nvae;
            }
            switch (alt74) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:556:33: ROW
                    {
                    ROW194=(Token)match(input,ROW,FOLLOW_ROW_in_fetchFirstClause3784); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ROW.add(ROW194);


                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:556:39: ROWS
                    {
                    ROWS195=(Token)match(input,ROWS,FOLLOW_ROWS_in_fetchFirstClause3788); if (state.failed) return retval; 
                    if ( state.backtracking==0 ) stream_ROWS.add(ROWS195);


                    }
                    break;

            }

            ONLY196=(Token)match(input,ONLY,FOLLOW_ONLY_in_fetchFirstClause3791); if (state.failed) return retval; 
            if ( state.backtracking==0 ) stream_ONLY.add(ONLY196);



            // AST REWRITE
            // elements: rows
            // token labels: rows
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            if ( state.backtracking==0 ) {
            retval.tree = root_0;
            RewriteRuleTokenStream stream_rows=new RewriteRuleTokenStream(adaptor,"token rows",rows);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 557:3: -> ^( PaginationNode $rows)
            {
                // src/astudy/parser/sql/QTemplate.g:557:6: ^( PaginationNode $rows)
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(PaginationNode, "PaginationNode"), root_1);

                adaptor.addChild(root_1, stream_rows.nextNode());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;}
            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "fetchFirstClause"

    public static class updateClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "updateClause"
    // src/astudy/parser/sql/QTemplate.g:560:1: updateClause : FOR UPDATE ( OF columnName ( COMMA columnName )* )? ;
    public final QTemplateParser.updateClause_return updateClause() throws RecognitionException {
        QTemplateParser.updateClause_return retval = new QTemplateParser.updateClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token FOR197=null;
        Token UPDATE198=null;
        Token OF199=null;
        Token COMMA201=null;
        QTemplateParser.columnName_return columnName200 = null;

        QTemplateParser.columnName_return columnName202 = null;


        Object FOR197_tree=null;
        Object UPDATE198_tree=null;
        Object OF199_tree=null;
        Object COMMA201_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:561:2: ( FOR UPDATE ( OF columnName ( COMMA columnName )* )? )
            // src/astudy/parser/sql/QTemplate.g:561:4: FOR UPDATE ( OF columnName ( COMMA columnName )* )?
            {
            root_0 = (Object)adaptor.nil();

            FOR197=(Token)match(input,FOR,FOLLOW_FOR_in_updateClause3814); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            FOR197_tree = (Object)adaptor.create(FOR197);
            adaptor.addChild(root_0, FOR197_tree);
            }
            UPDATE198=(Token)match(input,UPDATE,FOLLOW_UPDATE_in_updateClause3816); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            UPDATE198_tree = (Object)adaptor.create(UPDATE198);
            adaptor.addChild(root_0, UPDATE198_tree);
            }
            // src/astudy/parser/sql/QTemplate.g:561:15: ( OF columnName ( COMMA columnName )* )?
            int alt76=2;
            int LA76_0 = input.LA(1);

            if ( (LA76_0==OF) ) {
                alt76=1;
            }
            switch (alt76) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:561:16: OF columnName ( COMMA columnName )*
                    {
                    OF199=(Token)match(input,OF,FOLLOW_OF_in_updateClause3819); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    OF199_tree = (Object)adaptor.create(OF199);
                    adaptor.addChild(root_0, OF199_tree);
                    }
                    pushFollow(FOLLOW_columnName_in_updateClause3821);
                    columnName200=columnName();

                    state._fsp--;
                    if (state.failed) return retval;
                    if ( state.backtracking==0 ) adaptor.addChild(root_0, columnName200.getTree());
                    // src/astudy/parser/sql/QTemplate.g:561:30: ( COMMA columnName )*
                    loop75:
                    do {
                        int alt75=2;
                        int LA75_0 = input.LA(1);

                        if ( (LA75_0==COMMA) ) {
                            alt75=1;
                        }


                        switch (alt75) {
                    	case 1 :
                    	    // src/astudy/parser/sql/QTemplate.g:561:31: COMMA columnName
                    	    {
                    	    COMMA201=(Token)match(input,COMMA,FOLLOW_COMMA_in_updateClause3824); if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) {
                    	    COMMA201_tree = (Object)adaptor.create(COMMA201);
                    	    adaptor.addChild(root_0, COMMA201_tree);
                    	    }
                    	    pushFollow(FOLLOW_columnName_in_updateClause3826);
                    	    columnName202=columnName();

                    	    state._fsp--;
                    	    if (state.failed) return retval;
                    	    if ( state.backtracking==0 ) adaptor.addChild(root_0, columnName202.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop75;
                        }
                    } while (true);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "updateClause"

    public static class readOnlyClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "readOnlyClause"
    // src/astudy/parser/sql/QTemplate.g:564:1: readOnlyClause : FOR READ ONLY ;
    public final QTemplateParser.readOnlyClause_return readOnlyClause() throws RecognitionException {
        QTemplateParser.readOnlyClause_return retval = new QTemplateParser.readOnlyClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token FOR203=null;
        Token READ204=null;
        Token ONLY205=null;

        Object FOR203_tree=null;
        Object READ204_tree=null;
        Object ONLY205_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:565:2: ( FOR READ ONLY )
            // src/astudy/parser/sql/QTemplate.g:565:4: FOR READ ONLY
            {
            root_0 = (Object)adaptor.nil();

            FOR203=(Token)match(input,FOR,FOLLOW_FOR_in_readOnlyClause3844); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            FOR203_tree = (Object)adaptor.create(FOR203);
            adaptor.addChild(root_0, FOR203_tree);
            }
            READ204=(Token)match(input,READ,FOLLOW_READ_in_readOnlyClause3846); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            READ204_tree = (Object)adaptor.create(READ204);
            adaptor.addChild(root_0, READ204_tree);
            }
            ONLY205=(Token)match(input,ONLY,FOLLOW_ONLY_in_readOnlyClause3848); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            ONLY205_tree = (Object)adaptor.create(ONLY205);
            adaptor.addChild(root_0, ONLY205_tree);
            }

            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "readOnlyClause"

    public static class optimizeClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "optimizeClause"
    // src/astudy/parser/sql/QTemplate.g:568:1: optimizeClause : OPTIMIZE FOR ( INTEGER | ALL ) ( ROW | ROWS ) ;
    public final QTemplateParser.optimizeClause_return optimizeClause() throws RecognitionException {
        QTemplateParser.optimizeClause_return retval = new QTemplateParser.optimizeClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token OPTIMIZE206=null;
        Token FOR207=null;
        Token set208=null;
        Token set209=null;

        Object OPTIMIZE206_tree=null;
        Object FOR207_tree=null;
        Object set208_tree=null;
        Object set209_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:569:2: ( OPTIMIZE FOR ( INTEGER | ALL ) ( ROW | ROWS ) )
            // src/astudy/parser/sql/QTemplate.g:569:4: OPTIMIZE FOR ( INTEGER | ALL ) ( ROW | ROWS )
            {
            root_0 = (Object)adaptor.nil();

            OPTIMIZE206=(Token)match(input,OPTIMIZE,FOLLOW_OPTIMIZE_in_optimizeClause3861); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            OPTIMIZE206_tree = (Object)adaptor.create(OPTIMIZE206);
            adaptor.addChild(root_0, OPTIMIZE206_tree);
            }
            FOR207=(Token)match(input,FOR,FOLLOW_FOR_in_optimizeClause3863); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            FOR207_tree = (Object)adaptor.create(FOR207);
            adaptor.addChild(root_0, FOR207_tree);
            }
            set208=(Token)input.LT(1);
            if ( input.LA(1)==ALL||input.LA(1)==INTEGER ) {
                input.consume();
                if ( state.backtracking==0 ) adaptor.addChild(root_0, (Object)adaptor.create(set208));
                state.errorRecovery=false;state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }

            set209=(Token)input.LT(1);
            if ( (input.LA(1)>=ROW && input.LA(1)<=ROWS) ) {
                input.consume();
                if ( state.backtracking==0 ) adaptor.addChild(root_0, (Object)adaptor.create(set209));
                state.errorRecovery=false;state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return retval;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "optimizeClause"

    public static class isolationClause_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "isolationClause"
    // src/astudy/parser/sql/QTemplate.g:572:1: isolationClause : WITH ( NC | UR | CS ( KEEP LOCKS )? | RS | RR ) ;
    public final QTemplateParser.isolationClause_return isolationClause() throws RecognitionException {
        QTemplateParser.isolationClause_return retval = new QTemplateParser.isolationClause_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token WITH210=null;
        Token NC211=null;
        Token UR212=null;
        Token CS213=null;
        Token KEEP214=null;
        Token LOCKS215=null;
        Token RS216=null;
        Token RR217=null;

        Object WITH210_tree=null;
        Object NC211_tree=null;
        Object UR212_tree=null;
        Object CS213_tree=null;
        Object KEEP214_tree=null;
        Object LOCKS215_tree=null;
        Object RS216_tree=null;
        Object RR217_tree=null;

        try {
            // src/astudy/parser/sql/QTemplate.g:573:2: ( WITH ( NC | UR | CS ( KEEP LOCKS )? | RS | RR ) )
            // src/astudy/parser/sql/QTemplate.g:573:4: WITH ( NC | UR | CS ( KEEP LOCKS )? | RS | RR )
            {
            root_0 = (Object)adaptor.nil();

            WITH210=(Token)match(input,WITH,FOLLOW_WITH_in_isolationClause3892); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            WITH210_tree = (Object)adaptor.create(WITH210);
            adaptor.addChild(root_0, WITH210_tree);
            }
            // src/astudy/parser/sql/QTemplate.g:573:9: ( NC | UR | CS ( KEEP LOCKS )? | RS | RR )
            int alt78=5;
            switch ( input.LA(1) ) {
            case NC:
                {
                alt78=1;
                }
                break;
            case UR:
                {
                alt78=2;
                }
                break;
            case CS:
                {
                alt78=3;
                }
                break;
            case RS:
                {
                alt78=4;
                }
                break;
            case RR:
                {
                alt78=5;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 78, 0, input);

                throw nvae;
            }

            switch (alt78) {
                case 1 :
                    // src/astudy/parser/sql/QTemplate.g:573:10: NC
                    {
                    NC211=(Token)match(input,NC,FOLLOW_NC_in_isolationClause3895); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    NC211_tree = (Object)adaptor.create(NC211);
                    adaptor.addChild(root_0, NC211_tree);
                    }

                    }
                    break;
                case 2 :
                    // src/astudy/parser/sql/QTemplate.g:573:15: UR
                    {
                    UR212=(Token)match(input,UR,FOLLOW_UR_in_isolationClause3899); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    UR212_tree = (Object)adaptor.create(UR212);
                    adaptor.addChild(root_0, UR212_tree);
                    }

                    }
                    break;
                case 3 :
                    // src/astudy/parser/sql/QTemplate.g:573:20: CS ( KEEP LOCKS )?
                    {
                    CS213=(Token)match(input,CS,FOLLOW_CS_in_isolationClause3903); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    CS213_tree = (Object)adaptor.create(CS213);
                    adaptor.addChild(root_0, CS213_tree);
                    }
                    // src/astudy/parser/sql/QTemplate.g:573:23: ( KEEP LOCKS )?
                    int alt77=2;
                    int LA77_0 = input.LA(1);

                    if ( (LA77_0==KEEP) ) {
                        alt77=1;
                    }
                    switch (alt77) {
                        case 1 :
                            // src/astudy/parser/sql/QTemplate.g:573:24: KEEP LOCKS
                            {
                            KEEP214=(Token)match(input,KEEP,FOLLOW_KEEP_in_isolationClause3906); if (state.failed) return retval;
                            if ( state.backtracking==0 ) {
                            KEEP214_tree = (Object)adaptor.create(KEEP214);
                            adaptor.addChild(root_0, KEEP214_tree);
                            }
                            LOCKS215=(Token)match(input,LOCKS,FOLLOW_LOCKS_in_isolationClause3908); if (state.failed) return retval;
                            if ( state.backtracking==0 ) {
                            LOCKS215_tree = (Object)adaptor.create(LOCKS215);
                            adaptor.addChild(root_0, LOCKS215_tree);
                            }

                            }
                            break;

                    }


                    }
                    break;
                case 4 :
                    // src/astudy/parser/sql/QTemplate.g:573:39: RS
                    {
                    RS216=(Token)match(input,RS,FOLLOW_RS_in_isolationClause3914); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    RS216_tree = (Object)adaptor.create(RS216);
                    adaptor.addChild(root_0, RS216_tree);
                    }

                    }
                    break;
                case 5 :
                    // src/astudy/parser/sql/QTemplate.g:573:44: RR
                    {
                    RR217=(Token)match(input,RR,FOLLOW_RR_in_isolationClause3918); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    RR217_tree = (Object)adaptor.create(RR217);
                    adaptor.addChild(root_0, RR217_tree);
                    }

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "isolationClause"

    // $ANTLR start synpred1_QTemplate
    public final void synpred1_QTemplate_fragment() throws RecognitionException {   
        // src/astudy/parser/sql/QTemplate.g:489:4: ( LPAREN searchCondition RPAREN )
        // src/astudy/parser/sql/QTemplate.g:489:5: LPAREN searchCondition RPAREN
        {
        match(input,LPAREN,FOLLOW_LPAREN_in_synpred1_QTemplate3196); if (state.failed) return ;
        pushFollow(FOLLOW_searchCondition_in_synpred1_QTemplate3198);
        searchCondition();

        state._fsp--;
        if (state.failed) return ;
        match(input,RPAREN,FOLLOW_RPAREN_in_synpred1_QTemplate3200); if (state.failed) return ;

        }
    }
    // $ANTLR end synpred1_QTemplate

    // Delegated rules

    public final boolean synpred1_QTemplate() {
        state.backtracking++;
        int start = input.mark();
        try {
            synpred1_QTemplate_fragment(); // can never throw exception
        } catch (RecognitionException re) {
            System.err.println("impossible: "+re);
        }
        boolean success = !state.failed;
        input.rewind(start);
        state.backtracking--;
        state.failed=false;
        return success;
    }


    protected DFA14 dfa14 = new DFA14(this);
    protected DFA16 dfa16 = new DFA16(this);
    protected DFA17 dfa17 = new DFA17(this);
    protected DFA18 dfa18 = new DFA18(this);
    protected DFA19 dfa19 = new DFA19(this);
    protected DFA23 dfa23 = new DFA23(this);
    protected DFA24 dfa24 = new DFA24(this);
    protected DFA25 dfa25 = new DFA25(this);
    protected DFA27 dfa27 = new DFA27(this);
    protected DFA26 dfa26 = new DFA26(this);
    protected DFA30 dfa30 = new DFA30(this);
    protected DFA28 dfa28 = new DFA28(this);
    protected DFA32 dfa32 = new DFA32(this);
    protected DFA33 dfa33 = new DFA33(this);
    protected DFA38 dfa38 = new DFA38(this);
    protected DFA41 dfa41 = new DFA41(this);
    protected DFA42 dfa42 = new DFA42(this);
    protected DFA46 dfa46 = new DFA46(this);
    protected DFA48 dfa48 = new DFA48(this);
    protected DFA47 dfa47 = new DFA47(this);
    protected DFA52 dfa52 = new DFA52(this);
    protected DFA56 dfa56 = new DFA56(this);
    protected DFA58 dfa58 = new DFA58(this);
    protected DFA59 dfa59 = new DFA59(this);
    protected DFA60 dfa60 = new DFA60(this);
    protected DFA70 dfa70 = new DFA70(this);
    protected DFA62 dfa62 = new DFA62(this);
    protected DFA64 dfa64 = new DFA64(this);
    protected DFA66 dfa66 = new DFA66(this);
    protected DFA71 dfa71 = new DFA71(this);
    protected DFA73 dfa73 = new DFA73(this);
    static final String DFA14_eotS =
        "\12\uffff";
    static final String DFA14_eofS =
        "\1\1\11\uffff";
    static final String DFA14_minS =
        "\1\5\11\uffff";
    static final String DFA14_maxS =
        "\1\147\11\uffff";
    static final String DFA14_acceptS =
        "\1\uffff\1\2\7\uffff\1\1";
    static final String DFA14_specialS =
        "\12\uffff}>";
    static final String[] DFA14_transitionS = {
            "\1\1\3\uffff\1\1\5\uffff\1\1\3\uffff\1\1\1\uffff\1\1\10\uffff"+
            "\1\11\106\uffff\1\1\1\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA14_eot = DFA.unpackEncodedString(DFA14_eotS);
    static final short[] DFA14_eof = DFA.unpackEncodedString(DFA14_eofS);
    static final char[] DFA14_min = DFA.unpackEncodedStringToUnsignedChars(DFA14_minS);
    static final char[] DFA14_max = DFA.unpackEncodedStringToUnsignedChars(DFA14_maxS);
    static final short[] DFA14_accept = DFA.unpackEncodedString(DFA14_acceptS);
    static final short[] DFA14_special = DFA.unpackEncodedString(DFA14_specialS);
    static final short[][] DFA14_transition;

    static {
        int numStates = DFA14_transitionS.length;
        DFA14_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA14_transition[i] = DFA.unpackEncodedString(DFA14_transitionS[i]);
        }
    }

    class DFA14 extends DFA {

        public DFA14(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 14;
            this.eot = DFA14_eot;
            this.eof = DFA14_eof;
            this.min = DFA14_min;
            this.max = DFA14_max;
            this.accept = DFA14_accept;
            this.special = DFA14_special;
            this.transition = DFA14_transition;
        }
        public String getDescription() {
            return "()* loopback of 231:3: ( UNION ( DISTINCT | ALL )? subQueryExpression )*";
        }
    }
    static final String DFA16_eotS =
        "\15\uffff";
    static final String DFA16_eofS =
        "\1\2\14\uffff";
    static final String DFA16_minS =
        "\1\5\14\uffff";
    static final String DFA16_maxS =
        "\1\147\14\uffff";
    static final String DFA16_acceptS =
        "\1\uffff\1\1\1\2\12\uffff";
    static final String DFA16_specialS =
        "\15\uffff}>";
    static final String[] DFA16_transitionS = {
            "\1\2\3\uffff\1\2\5\uffff\1\2\3\uffff\1\2\1\uffff\1\2\10\uffff"+
            "\1\2\2\uffff\1\1\2\2\101\uffff\1\2\1\uffff\1\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA16_eot = DFA.unpackEncodedString(DFA16_eotS);
    static final short[] DFA16_eof = DFA.unpackEncodedString(DFA16_eofS);
    static final char[] DFA16_min = DFA.unpackEncodedStringToUnsignedChars(DFA16_minS);
    static final char[] DFA16_max = DFA.unpackEncodedStringToUnsignedChars(DFA16_maxS);
    static final short[] DFA16_accept = DFA.unpackEncodedString(DFA16_acceptS);
    static final short[] DFA16_special = DFA.unpackEncodedString(DFA16_specialS);
    static final short[][] DFA16_transition;

    static {
        int numStates = DFA16_transitionS.length;
        DFA16_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA16_transition[i] = DFA.unpackEncodedString(DFA16_transitionS[i]);
        }
    }

    class DFA16 extends DFA {

        public DFA16(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 16;
            this.eot = DFA16_eot;
            this.eof = DFA16_eof;
            this.min = DFA16_min;
            this.max = DFA16_max;
            this.accept = DFA16_accept;
            this.special = DFA16_special;
            this.transition = DFA16_transition;
        }
        public String getDescription() {
            return "247:3: ( whereClause )?";
        }
    }
    static final String DFA17_eotS =
        "\14\uffff";
    static final String DFA17_eofS =
        "\1\2\13\uffff";
    static final String DFA17_minS =
        "\1\5\13\uffff";
    static final String DFA17_maxS =
        "\1\147\13\uffff";
    static final String DFA17_acceptS =
        "\1\uffff\1\1\1\2\11\uffff";
    static final String DFA17_specialS =
        "\14\uffff}>";
    static final String[] DFA17_transitionS = {
            "\1\2\3\uffff\1\2\5\uffff\1\2\3\uffff\1\2\1\uffff\1\2\10\uffff"+
            "\1\2\3\uffff\1\1\1\2\101\uffff\1\2\1\uffff\1\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA17_eot = DFA.unpackEncodedString(DFA17_eotS);
    static final short[] DFA17_eof = DFA.unpackEncodedString(DFA17_eofS);
    static final char[] DFA17_min = DFA.unpackEncodedStringToUnsignedChars(DFA17_minS);
    static final char[] DFA17_max = DFA.unpackEncodedStringToUnsignedChars(DFA17_maxS);
    static final short[] DFA17_accept = DFA.unpackEncodedString(DFA17_acceptS);
    static final short[] DFA17_special = DFA.unpackEncodedString(DFA17_specialS);
    static final short[][] DFA17_transition;

    static {
        int numStates = DFA17_transitionS.length;
        DFA17_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA17_transition[i] = DFA.unpackEncodedString(DFA17_transitionS[i]);
        }
    }

    class DFA17 extends DFA {

        public DFA17(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 17;
            this.eot = DFA17_eot;
            this.eof = DFA17_eof;
            this.min = DFA17_min;
            this.max = DFA17_max;
            this.accept = DFA17_accept;
            this.special = DFA17_special;
            this.transition = DFA17_transition;
        }
        public String getDescription() {
            return "248:3: ( groupByClause )?";
        }
    }
    static final String DFA18_eotS =
        "\13\uffff";
    static final String DFA18_eofS =
        "\1\2\12\uffff";
    static final String DFA18_minS =
        "\1\5\12\uffff";
    static final String DFA18_maxS =
        "\1\147\12\uffff";
    static final String DFA18_acceptS =
        "\1\uffff\1\1\1\2\10\uffff";
    static final String DFA18_specialS =
        "\13\uffff}>";
    static final String[] DFA18_transitionS = {
            "\1\2\3\uffff\1\2\5\uffff\1\2\3\uffff\1\2\1\uffff\1\2\10\uffff"+
            "\1\2\4\uffff\1\1\101\uffff\1\2\1\uffff\1\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA18_eot = DFA.unpackEncodedString(DFA18_eotS);
    static final short[] DFA18_eof = DFA.unpackEncodedString(DFA18_eofS);
    static final char[] DFA18_min = DFA.unpackEncodedStringToUnsignedChars(DFA18_minS);
    static final char[] DFA18_max = DFA.unpackEncodedStringToUnsignedChars(DFA18_maxS);
    static final short[] DFA18_accept = DFA.unpackEncodedString(DFA18_acceptS);
    static final short[] DFA18_special = DFA.unpackEncodedString(DFA18_specialS);
    static final short[][] DFA18_transition;

    static {
        int numStates = DFA18_transitionS.length;
        DFA18_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA18_transition[i] = DFA.unpackEncodedString(DFA18_transitionS[i]);
        }
    }

    class DFA18 extends DFA {

        public DFA18(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 18;
            this.eot = DFA18_eot;
            this.eof = DFA18_eof;
            this.min = DFA18_min;
            this.max = DFA18_max;
            this.accept = DFA18_accept;
            this.special = DFA18_special;
            this.transition = DFA18_transition;
        }
        public String getDescription() {
            return "249:3: ( havingClause )?";
        }
    }
    static final String DFA19_eotS =
        "\23\uffff";
    static final String DFA19_eofS =
        "\23\uffff";
    static final String DFA19_minS =
        "\1\24\22\uffff";
    static final String DFA19_maxS =
        "\1\u0080\22\uffff";
    static final String DFA19_acceptS =
        "\1\uffff\1\1\1\2\1\3\17\uffff";
    static final String DFA19_specialS =
        "\23\uffff}>";
    static final String[] DFA19_transitionS = {
            "\1\1\12\uffff\1\2\31\uffff\1\3\4\uffff\1\3\45\uffff\1\3\1\uffff"+
            "\1\3\7\uffff\2\3\3\uffff\6\3\3\uffff\5\3",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA19_eot = DFA.unpackEncodedString(DFA19_eotS);
    static final short[] DFA19_eof = DFA.unpackEncodedString(DFA19_eofS);
    static final char[] DFA19_min = DFA.unpackEncodedStringToUnsignedChars(DFA19_minS);
    static final char[] DFA19_max = DFA.unpackEncodedStringToUnsignedChars(DFA19_maxS);
    static final short[] DFA19_accept = DFA.unpackEncodedString(DFA19_acceptS);
    static final short[] DFA19_special = DFA.unpackEncodedString(DFA19_specialS);
    static final short[][] DFA19_transition;

    static {
        int numStates = DFA19_transitionS.length;
        DFA19_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA19_transition[i] = DFA.unpackEncodedString(DFA19_transitionS[i]);
        }
    }

    class DFA19 extends DFA {

        public DFA19(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 19;
            this.eot = DFA19_eot;
            this.eof = DFA19_eof;
            this.min = DFA19_min;
            this.max = DFA19_max;
            this.accept = DFA19_accept;
            this.special = DFA19_special;
            this.transition = DFA19_transition;
        }
        public String getDescription() {
            return "261:11: ( ALL | DISTINCT )?";
        }
    }
    static final String DFA23_eotS =
        "\21\uffff";
    static final String DFA23_eofS =
        "\21\uffff";
    static final String DFA23_minS =
        "\1\71\20\uffff";
    static final String DFA23_maxS =
        "\1\u0080\20\uffff";
    static final String DFA23_acceptS =
        "\1\uffff\1\1\1\2\1\3\15\uffff";
    static final String DFA23_specialS =
        "\21\uffff}>";
    static final String[] DFA23_transitionS = {
            "\1\3\4\uffff\1\3\45\uffff\1\1\1\uffff\1\3\7\uffff\2\3\3\uffff"+
            "\4\3\1\2\1\3\3\uffff\5\3",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA23_eot = DFA.unpackEncodedString(DFA23_eotS);
    static final short[] DFA23_eof = DFA.unpackEncodedString(DFA23_eofS);
    static final char[] DFA23_min = DFA.unpackEncodedStringToUnsignedChars(DFA23_minS);
    static final char[] DFA23_max = DFA.unpackEncodedStringToUnsignedChars(DFA23_maxS);
    static final short[] DFA23_accept = DFA.unpackEncodedString(DFA23_acceptS);
    static final short[] DFA23_special = DFA.unpackEncodedString(DFA23_specialS);
    static final short[][] DFA23_transition;

    static {
        int numStates = DFA23_transitionS.length;
        DFA23_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA23_transition[i] = DFA.unpackEncodedString(DFA23_transitionS[i]);
        }
    }

    class DFA23 extends DFA {

        public DFA23(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 23;
            this.eot = DFA23_eot;
            this.eof = DFA23_eof;
            this.min = DFA23_min;
            this.max = DFA23_max;
            this.accept = DFA23_accept;
            this.special = DFA23_special;
            this.transition = DFA23_transition;
        }
        public String getDescription() {
            return "267:1: selectItem : ( STAR -> ^( NameNode STAR ) | TABLE_COLUMNS -> ^( NameNode TABLE_COLUMNS ) | expression ( ( AS )? columnName )? -> ^( NameNode expression ) ( ^( AliasNode columnName ) )? );";
        }
    }
    static final String DFA24_eotS =
        "\53\uffff";
    static final String DFA24_eofS =
        "\1\1\52\uffff";
    static final String DFA24_minS =
        "\1\4\52\uffff";
    static final String DFA24_maxS =
        "\1\170\52\uffff";
    static final String DFA24_acceptS =
        "\1\uffff\1\2\47\uffff\1\1\1\uffff";
    static final String DFA24_specialS =
        "\53\uffff}>";
    static final String[] DFA24_transitionS = {
            "\2\1\1\uffff\3\1\1\uffff\1\1\3\uffff\1\1\3\uffff\1\1\1\uffff"+
            "\1\1\10\uffff\1\1\1\uffff\11\1\1\uffff\5\1\2\uffff\1\1\1\uffff"+
            "\4\1\1\uffff\1\51\1\uffff\4\1\44\uffff\1\1\2\51\11\1\4\51\6"+
            "\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA24_eot = DFA.unpackEncodedString(DFA24_eotS);
    static final short[] DFA24_eof = DFA.unpackEncodedString(DFA24_eofS);
    static final char[] DFA24_min = DFA.unpackEncodedStringToUnsignedChars(DFA24_minS);
    static final char[] DFA24_max = DFA.unpackEncodedStringToUnsignedChars(DFA24_maxS);
    static final short[] DFA24_accept = DFA.unpackEncodedString(DFA24_acceptS);
    static final short[] DFA24_special = DFA.unpackEncodedString(DFA24_specialS);
    static final short[][] DFA24_transition;

    static {
        int numStates = DFA24_transitionS.length;
        DFA24_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA24_transition[i] = DFA.unpackEncodedString(DFA24_transitionS[i]);
        }
    }

    class DFA24 extends DFA {

        public DFA24(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 24;
            this.eot = DFA24_eot;
            this.eof = DFA24_eof;
            this.min = DFA24_min;
            this.max = DFA24_max;
            this.accept = DFA24_accept;
            this.special = DFA24_special;
            this.transition = DFA24_transition;
        }
        public String getDescription() {
            return "()* loopback of 277:20: ( binaryOperator subExpression )*";
        }
    }
    static final String DFA25_eotS =
        "\17\uffff";
    static final String DFA25_eofS =
        "\17\uffff";
    static final String DFA25_minS =
        "\1\71\16\uffff";
    static final String DFA25_maxS =
        "\1\u0080\16\uffff";
    static final String DFA25_acceptS =
        "\1\uffff\1\1\1\2\14\uffff";
    static final String DFA25_specialS =
        "\17\uffff}>";
    static final String[] DFA25_transitionS = {
            "\1\2\4\uffff\1\2\47\uffff\1\2\7\uffff\2\1\3\uffff\4\2\1\uffff"+
            "\1\2\3\uffff\5\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA25_eot = DFA.unpackEncodedString(DFA25_eotS);
    static final short[] DFA25_eof = DFA.unpackEncodedString(DFA25_eofS);
    static final char[] DFA25_min = DFA.unpackEncodedStringToUnsignedChars(DFA25_minS);
    static final char[] DFA25_max = DFA.unpackEncodedStringToUnsignedChars(DFA25_maxS);
    static final short[] DFA25_accept = DFA.unpackEncodedString(DFA25_acceptS);
    static final short[] DFA25_special = DFA.unpackEncodedString(DFA25_specialS);
    static final short[][] DFA25_transition;

    static {
        int numStates = DFA25_transitionS.length;
        DFA25_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA25_transition[i] = DFA.unpackEncodedString(DFA25_transitionS[i]);
        }
    }

    class DFA25 extends DFA {

        public DFA25(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 25;
            this.eot = DFA25_eot;
            this.eof = DFA25_eof;
            this.min = DFA25_min;
            this.max = DFA25_max;
            this.accept = DFA25_accept;
            this.special = DFA25_special;
            this.transition = DFA25_transition;
        }
        public String getDescription() {
            return "282:3: ( unaryOperator )?";
        }
    }
    static final String DFA27_eotS =
        "\71\uffff";
    static final String DFA27_eofS =
        "\1\uffff\1\20\67\uffff";
    static final String DFA27_minS =
        "\1\71\1\4\67\uffff";
    static final String DFA27_maxS =
        "\1\u0080\1\170\67\uffff";
    static final String DFA27_acceptS =
        "\2\uffff\1\2\1\3\10\uffff\1\5\1\6\1\7\1\1\1\4\50\uffff";
    static final String DFA27_specialS =
        "\71\uffff}>";
    static final String[] DFA27_transitionS = {
            "\1\16\4\uffff\1\15\47\uffff\1\2\7\uffff\2\3\3\uffff\4\3\1\uffff"+
            "\1\1\3\uffff\4\3\1\14",
            "\2\20\1\uffff\3\20\1\uffff\1\20\3\uffff\1\20\3\uffff\1\20"+
            "\1\uffff\1\20\10\uffff\1\20\1\uffff\11\20\1\uffff\5\20\2\uffff"+
            "\1\20\1\uffff\4\20\1\uffff\1\20\1\uffff\4\20\44\uffff\4\20\1"+
            "\17\13\20\6\uffff\1\20",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA27_eot = DFA.unpackEncodedString(DFA27_eotS);
    static final short[] DFA27_eof = DFA.unpackEncodedString(DFA27_eofS);
    static final char[] DFA27_min = DFA.unpackEncodedStringToUnsignedChars(DFA27_minS);
    static final char[] DFA27_max = DFA.unpackEncodedStringToUnsignedChars(DFA27_maxS);
    static final short[] DFA27_accept = DFA.unpackEncodedString(DFA27_acceptS);
    static final short[] DFA27_special = DFA.unpackEncodedString(DFA27_specialS);
    static final short[][] DFA27_transition;

    static {
        int numStates = DFA27_transitionS.length;
        DFA27_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA27_transition[i] = DFA.unpackEncodedString(DFA27_transitionS[i]);
        }
    }

    class DFA27 extends DFA {

        public DFA27(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 27;
            this.eot = DFA27_eot;
            this.eof = DFA27_eof;
            this.min = DFA27_min;
            this.max = DFA27_max;
            this.accept = DFA27_accept;
            this.special = DFA27_special;
            this.transition = DFA27_transition;
        }
        public String getDescription() {
            return "283:3: ( function | LPAREN ( scalarSubSelect | expression ) RPAREN | constant | columnName | specialRegister | castSpecification | caseExpression )";
        }
    }
    static final String DFA26_eotS =
        "\20\uffff";
    static final String DFA26_eofS =
        "\20\uffff";
    static final String DFA26_minS =
        "\1\35\17\uffff";
    static final String DFA26_maxS =
        "\1\u0080\17\uffff";
    static final String DFA26_acceptS =
        "\1\uffff\1\1\1\2\15\uffff";
    static final String DFA26_specialS =
        "\20\uffff}>";
    static final String[] DFA26_transitionS = {
            "\1\1\33\uffff\1\2\4\uffff\1\2\47\uffff\1\2\7\uffff\2\2\3\uffff"+
            "\4\2\1\uffff\1\2\3\uffff\5\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA26_eot = DFA.unpackEncodedString(DFA26_eotS);
    static final short[] DFA26_eof = DFA.unpackEncodedString(DFA26_eofS);
    static final char[] DFA26_min = DFA.unpackEncodedStringToUnsignedChars(DFA26_minS);
    static final char[] DFA26_max = DFA.unpackEncodedStringToUnsignedChars(DFA26_maxS);
    static final short[] DFA26_accept = DFA.unpackEncodedString(DFA26_acceptS);
    static final short[] DFA26_special = DFA.unpackEncodedString(DFA26_specialS);
    static final short[][] DFA26_transition;

    static {
        int numStates = DFA26_transitionS.length;
        DFA26_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA26_transition[i] = DFA.unpackEncodedString(DFA26_transitionS[i]);
        }
    }

    class DFA26 extends DFA {

        public DFA26(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 26;
            this.eot = DFA26_eot;
            this.eof = DFA26_eof;
            this.min = DFA26_min;
            this.max = DFA26_max;
            this.accept = DFA26_accept;
            this.special = DFA26_special;
            this.transition = DFA26_transition;
        }
        public String getDescription() {
            return "285:14: ( scalarSubSelect | expression )";
        }
    }
    static final String DFA30_eotS =
        "\23\uffff";
    static final String DFA30_eofS =
        "\23\uffff";
    static final String DFA30_minS =
        "\1\24\22\uffff";
    static final String DFA30_maxS =
        "\1\u0080\22\uffff";
    static final String DFA30_acceptS =
        "\1\uffff\1\1\1\2\17\uffff\1\3";
    static final String DFA30_specialS =
        "\23\uffff}>";
    static final String[] DFA30_transitionS = {
            "\1\2\12\uffff\1\2\31\uffff\1\2\4\uffff\1\2\45\uffff\1\1\1\uffff"+
            "\1\2\1\22\6\uffff\2\2\3\uffff\4\2\1\uffff\1\2\3\uffff\5\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA30_eot = DFA.unpackEncodedString(DFA30_eotS);
    static final short[] DFA30_eof = DFA.unpackEncodedString(DFA30_eofS);
    static final char[] DFA30_min = DFA.unpackEncodedStringToUnsignedChars(DFA30_minS);
    static final char[] DFA30_max = DFA.unpackEncodedStringToUnsignedChars(DFA30_maxS);
    static final short[] DFA30_accept = DFA.unpackEncodedString(DFA30_acceptS);
    static final short[] DFA30_special = DFA.unpackEncodedString(DFA30_specialS);
    static final short[][] DFA30_transition;

    static {
        int numStates = DFA30_transitionS.length;
        DFA30_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA30_transition[i] = DFA.unpackEncodedString(DFA30_transitionS[i]);
        }
    }

    class DFA30 extends DFA {

        public DFA30(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 30;
            this.eot = DFA30_eot;
            this.eof = DFA30_eof;
            this.min = DFA30_min;
            this.max = DFA30_max;
            this.accept = DFA30_accept;
            this.special = DFA30_special;
            this.transition = DFA30_transition;
        }
        public String getDescription() {
            return "310:4: ( STAR | ( ALL | DISTINCT )? ( expression ( COMMA expression )* ) )?";
        }
    }
    static final String DFA28_eotS =
        "\21\uffff";
    static final String DFA28_eofS =
        "\21\uffff";
    static final String DFA28_minS =
        "\1\24\20\uffff";
    static final String DFA28_maxS =
        "\1\u0080\20\uffff";
    static final String DFA28_acceptS =
        "\1\uffff\1\1\1\2\1\3\15\uffff";
    static final String DFA28_specialS =
        "\21\uffff}>";
    static final String[] DFA28_transitionS = {
            "\1\1\12\uffff\1\2\31\uffff\1\3\4\uffff\1\3\47\uffff\1\3\7\uffff"+
            "\2\3\3\uffff\4\3\1\uffff\1\3\3\uffff\5\3",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA28_eot = DFA.unpackEncodedString(DFA28_eotS);
    static final short[] DFA28_eof = DFA.unpackEncodedString(DFA28_eofS);
    static final char[] DFA28_min = DFA.unpackEncodedStringToUnsignedChars(DFA28_minS);
    static final char[] DFA28_max = DFA.unpackEncodedStringToUnsignedChars(DFA28_maxS);
    static final short[] DFA28_accept = DFA.unpackEncodedString(DFA28_acceptS);
    static final short[] DFA28_special = DFA.unpackEncodedString(DFA28_specialS);
    static final short[][] DFA28_transition;

    static {
        int numStates = DFA28_transitionS.length;
        DFA28_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA28_transition[i] = DFA.unpackEncodedString(DFA28_transitionS[i]);
        }
    }

    class DFA28 extends DFA {

        public DFA28(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 28;
            this.eot = DFA28_eot;
            this.eof = DFA28_eof;
            this.min = DFA28_min;
            this.max = DFA28_max;
            this.accept = DFA28_accept;
            this.special = DFA28_special;
            this.transition = DFA28_transition;
        }
        public String getDescription() {
            return "310:13: ( ALL | DISTINCT )?";
        }
    }
    static final String DFA32_eotS =
        "\12\uffff";
    static final String DFA32_eofS =
        "\12\uffff";
    static final String DFA32_minS =
        "\1\156\11\uffff";
    static final String DFA32_maxS =
        "\1\177\11\uffff";
    static final String DFA32_acceptS =
        "\1\uffff\1\1\1\uffff\1\2\1\3\1\4\1\5\1\6\1\7\1\10";
    static final String DFA32_specialS =
        "\12\uffff}>";
    static final String[] DFA32_transitionS = {
            "\2\1\3\uffff\1\1\1\3\1\4\1\5\5\uffff\1\6\1\7\1\10\1\11",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA32_eot = DFA.unpackEncodedString(DFA32_eotS);
    static final short[] DFA32_eof = DFA.unpackEncodedString(DFA32_eofS);
    static final char[] DFA32_min = DFA.unpackEncodedStringToUnsignedChars(DFA32_minS);
    static final char[] DFA32_max = DFA.unpackEncodedStringToUnsignedChars(DFA32_maxS);
    static final short[] DFA32_accept = DFA.unpackEncodedString(DFA32_acceptS);
    static final short[] DFA32_special = DFA.unpackEncodedString(DFA32_specialS);
    static final short[][] DFA32_transition;

    static {
        int numStates = DFA32_transitionS.length;
        DFA32_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA32_transition[i] = DFA.unpackEncodedString(DFA32_transitionS[i]);
        }
    }

    class DFA32 extends DFA {

        public DFA32(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 32;
            this.eot = DFA32_eot;
            this.eof = DFA32_eof;
            this.min = DFA32_min;
            this.max = DFA32_max;
            this.accept = DFA32_accept;
            this.special = DFA32_special;
            this.transition = DFA32_transition;
        }
        public String getDescription() {
            return "315:1: constant : ( ( PLUS | MINUS )? INTEGER | DECIMAL | FLOAT_POINT | CHARACTER_STRING | 'GRAPHIC_STRING' | 'BINARY-STRING' | 'DECIMAL_POINT' | 'Delimiters' );";
        }
    }
    static final String DFA33_eotS =
        "\17\uffff";
    static final String DFA33_eofS =
        "\1\uffff\1\16\15\uffff";
    static final String DFA33_minS =
        "\2\146\15\uffff";
    static final String DFA33_maxS =
        "\1\177\1\170\15\uffff";
    static final String DFA33_acceptS =
        "\2\uffff\1\2\1\3\10\uffff\1\1\1\4\1\5";
    static final String DFA33_specialS =
        "\17\uffff}>";
    static final String[] DFA33_transitionS = {
            "\1\2\7\uffff\2\3\3\uffff\4\3\1\uffff\1\1\3\uffff\4\3",
            "\1\14\21\uffff\1\15",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA33_eot = DFA.unpackEncodedString(DFA33_eotS);
    static final short[] DFA33_eof = DFA.unpackEncodedString(DFA33_eofS);
    static final char[] DFA33_min = DFA.unpackEncodedStringToUnsignedChars(DFA33_minS);
    static final char[] DFA33_max = DFA.unpackEncodedStringToUnsignedChars(DFA33_maxS);
    static final short[] DFA33_accept = DFA.unpackEncodedString(DFA33_acceptS);
    static final short[] DFA33_special = DFA.unpackEncodedString(DFA33_specialS);
    static final short[][] DFA33_transition;

    static {
        int numStates = DFA33_transitionS.length;
        DFA33_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA33_transition[i] = DFA.unpackEncodedString(DFA33_transitionS[i]);
        }
    }

    class DFA33 extends DFA {

        public DFA33(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 33;
            this.eot = DFA33_eot;
            this.eof = DFA33_eof;
            this.min = DFA33_min;
            this.max = DFA33_max;
            this.accept = DFA33_accept;
            this.special = DFA33_special;
            this.transition = DFA33_transition;
        }
        public String getDescription() {
            return "350:4: ( function | LPAREN expression RPAREN | constant | columnName | )";
        }
    }
    static final String DFA38_eotS =
        "\20\uffff";
    static final String DFA38_eofS =
        "\20\uffff";
    static final String DFA38_minS =
        "\1\71\17\uffff";
    static final String DFA38_maxS =
        "\1\u0080\17\uffff";
    static final String DFA38_acceptS =
        "\1\uffff\1\1\15\uffff\1\2";
    static final String DFA38_specialS =
        "\20\uffff}>";
    static final String[] DFA38_transitionS = {
            "\1\1\1\17\3\uffff\1\1\47\uffff\1\1\7\uffff\2\1\3\uffff\4\1"+
            "\1\uffff\1\1\3\uffff\5\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA38_eot = DFA.unpackEncodedString(DFA38_eotS);
    static final short[] DFA38_eof = DFA.unpackEncodedString(DFA38_eofS);
    static final char[] DFA38_min = DFA.unpackEncodedStringToUnsignedChars(DFA38_minS);
    static final char[] DFA38_max = DFA.unpackEncodedStringToUnsignedChars(DFA38_maxS);
    static final short[] DFA38_accept = DFA.unpackEncodedString(DFA38_acceptS);
    static final short[] DFA38_special = DFA.unpackEncodedString(DFA38_specialS);
    static final short[][] DFA38_transition;

    static {
        int numStates = DFA38_transitionS.length;
        DFA38_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA38_transition[i] = DFA.unpackEncodedString(DFA38_transitionS[i]);
        }
    }

    class DFA38 extends DFA {

        public DFA38(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 38;
            this.eot = DFA38_eot;
            this.eof = DFA38_eof;
            this.min = DFA38_min;
            this.max = DFA38_max;
            this.accept = DFA38_accept;
            this.special = DFA38_special;
            this.transition = DFA38_transition;
        }
        public String getDescription() {
            return "369:10: (exp= expression ( WHEN i+= expression THEN i+= expression )+ | ( WHEN i+= searchCondition THEN i+= expression )+ )";
        }
    }
    static final String DFA41_eotS =
        "\16\uffff";
    static final String DFA41_eofS =
        "\1\1\15\uffff";
    static final String DFA41_minS =
        "\1\5\15\uffff";
    static final String DFA41_maxS =
        "\1\147\15\uffff";
    static final String DFA41_acceptS =
        "\1\uffff\1\2\13\uffff\1\1";
    static final String DFA41_specialS =
        "\16\uffff}>";
    static final String[] DFA41_transitionS = {
            "\1\1\3\uffff\1\1\5\uffff\1\1\3\uffff\1\1\1\uffff\1\1\10\uffff"+
            "\1\1\2\uffff\3\1\76\uffff\1\15\2\uffff\1\1\1\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA41_eot = DFA.unpackEncodedString(DFA41_eotS);
    static final short[] DFA41_eof = DFA.unpackEncodedString(DFA41_eofS);
    static final char[] DFA41_min = DFA.unpackEncodedStringToUnsignedChars(DFA41_minS);
    static final char[] DFA41_max = DFA.unpackEncodedStringToUnsignedChars(DFA41_maxS);
    static final short[] DFA41_accept = DFA.unpackEncodedString(DFA41_acceptS);
    static final short[] DFA41_special = DFA.unpackEncodedString(DFA41_specialS);
    static final short[][] DFA41_transition;

    static {
        int numStates = DFA41_transitionS.length;
        DFA41_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA41_transition[i] = DFA.unpackEncodedString(DFA41_transitionS[i]);
        }
    }

    class DFA41 extends DFA {

        public DFA41(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 41;
            this.eot = DFA41_eot;
            this.eof = DFA41_eof;
            this.min = DFA41_min;
            this.max = DFA41_max;
            this.accept = DFA41_accept;
            this.special = DFA41_special;
            this.transition = DFA41_transition;
        }
        public String getDescription() {
            return "()* loopback of 405:24: ( COMMA tableReference )*";
        }
    }
    static final String DFA42_eotS =
        "\31\uffff";
    static final String DFA42_eofS =
        "\1\3\30\uffff";
    static final String DFA42_minS =
        "\1\4\30\uffff";
    static final String DFA42_maxS =
        "\1\170\30\uffff";
    static final String DFA42_acceptS =
        "\1\uffff\2\1\1\2\25\uffff";
    static final String DFA42_specialS =
        "\31\uffff}>";
    static final String[] DFA42_transitionS = {
            "\1\1\1\3\3\uffff\1\3\5\uffff\1\3\3\uffff\1\3\1\uffff\1\3\10"+
            "\uffff\1\3\1\uffff\11\3\1\uffff\2\3\66\uffff\1\3\2\uffff\3\3"+
            "\20\uffff\1\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA42_eot = DFA.unpackEncodedString(DFA42_eotS);
    static final short[] DFA42_eof = DFA.unpackEncodedString(DFA42_eofS);
    static final char[] DFA42_min = DFA.unpackEncodedStringToUnsignedChars(DFA42_minS);
    static final char[] DFA42_max = DFA.unpackEncodedStringToUnsignedChars(DFA42_maxS);
    static final short[] DFA42_accept = DFA.unpackEncodedString(DFA42_acceptS);
    static final short[] DFA42_special = DFA.unpackEncodedString(DFA42_specialS);
    static final short[][] DFA42_transition;

    static {
        int numStates = DFA42_transitionS.length;
        DFA42_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA42_transition[i] = DFA.unpackEncodedString(DFA42_transitionS[i]);
        }
    }

    class DFA42 extends DFA {

        public DFA42(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 42;
            this.eot = DFA42_eot;
            this.eof = DFA42_eof;
            this.min = DFA42_min;
            this.max = DFA42_max;
            this.accept = DFA42_accept;
            this.special = DFA42_special;
            this.transition = DFA42_transition;
        }
        public String getDescription() {
            return "410:40: (refcol= correlationClause )?";
        }
    }
    static final String DFA46_eotS =
        "\20\uffff";
    static final String DFA46_eofS =
        "\20\uffff";
    static final String DFA46_minS =
        "\1\71\17\uffff";
    static final String DFA46_maxS =
        "\1\u0080\17\uffff";
    static final String DFA46_acceptS =
        "\1\uffff\1\1\15\uffff\1\2";
    static final String DFA46_specialS =
        "\20\uffff}>";
    static final String[] DFA46_transitionS = {
            "\1\1\4\uffff\1\1\47\uffff\1\1\1\17\6\uffff\2\1\3\uffff\4\1"+
            "\1\uffff\1\1\3\uffff\5\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA46_eot = DFA.unpackEncodedString(DFA46_eotS);
    static final short[] DFA46_eof = DFA.unpackEncodedString(DFA46_eofS);
    static final char[] DFA46_min = DFA.unpackEncodedStringToUnsignedChars(DFA46_minS);
    static final char[] DFA46_max = DFA.unpackEncodedStringToUnsignedChars(DFA46_maxS);
    static final short[] DFA46_accept = DFA.unpackEncodedString(DFA46_acceptS);
    static final short[] DFA46_special = DFA.unpackEncodedString(DFA46_specialS);
    static final short[][] DFA46_transition;

    static {
        int numStates = DFA46_transitionS.length;
        DFA46_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA46_transition[i] = DFA.unpackEncodedString(DFA46_transitionS[i]);
        }
    }

    class DFA46 extends DFA {

        public DFA46(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 46;
            this.eot = DFA46_eot;
            this.eof = DFA46_eof;
            this.min = DFA46_min;
            this.max = DFA46_max;
            this.accept = DFA46_accept;
            this.special = DFA46_special;
            this.transition = DFA46_transition;
        }
        public String getDescription() {
            return "425:11: (params+= expression ( COMMA params+= expression )* )?";
        }
    }
    static final String DFA48_eotS =
        "\30\uffff";
    static final String DFA48_eofS =
        "\1\12\27\uffff";
    static final String DFA48_minS =
        "\1\5\27\uffff";
    static final String DFA48_maxS =
        "\1\170\27\uffff";
    static final String DFA48_acceptS =
        "\1\uffff\11\1\1\2\15\uffff";
    static final String DFA48_specialS =
        "\30\uffff}>";
    static final String[] DFA48_transitionS = {
            "\1\12\3\uffff\1\12\5\uffff\1\12\3\uffff\1\12\1\uffff\1\12\10"+
            "\uffff\1\12\1\uffff\1\11\3\12\1\1\1\6\1\2\1\3\1\4\1\uffff\1"+
            "\5\1\12\66\uffff\1\12\2\uffff\1\12\1\10\1\12\20\uffff\1\7",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA48_eot = DFA.unpackEncodedString(DFA48_eotS);
    static final short[] DFA48_eof = DFA.unpackEncodedString(DFA48_eofS);
    static final char[] DFA48_min = DFA.unpackEncodedStringToUnsignedChars(DFA48_minS);
    static final char[] DFA48_max = DFA.unpackEncodedStringToUnsignedChars(DFA48_maxS);
    static final short[] DFA48_accept = DFA.unpackEncodedString(DFA48_acceptS);
    static final short[] DFA48_special = DFA.unpackEncodedString(DFA48_specialS);
    static final short[][] DFA48_transition;

    static {
        int numStates = DFA48_transitionS.length;
        DFA48_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA48_transition[i] = DFA.unpackEncodedString(DFA48_transitionS[i]);
        }
    }

    class DFA48 extends DFA {

        public DFA48(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 48;
            this.eot = DFA48_eot;
            this.eof = DFA48_eof;
            this.min = DFA48_min;
            this.max = DFA48_max;
            this.accept = DFA48_accept;
            this.special = DFA48_special;
            this.transition = DFA48_transition;
        }
        public String getDescription() {
            return "431:4: ( ( joinedTable | singleTable | nestedTableExpression | tableFunction ) tableReference )?";
        }
    }
    static final String DFA47_eotS =
        "\12\uffff";
    static final String DFA47_eofS =
        "\12\uffff";
    static final String DFA47_minS =
        "\1\40\11\uffff";
    static final String DFA47_maxS =
        "\1\170\11\uffff";
    static final String DFA47_acceptS =
        "\1\uffff\1\1\5\uffff\1\2\1\3\1\4";
    static final String DFA47_specialS =
        "\12\uffff}>";
    static final String[] DFA47_transitionS = {
            "\1\11\3\uffff\5\1\1\uffff\1\1\73\uffff\1\10\21\uffff\1\7",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA47_eot = DFA.unpackEncodedString(DFA47_eotS);
    static final short[] DFA47_eof = DFA.unpackEncodedString(DFA47_eofS);
    static final char[] DFA47_min = DFA.unpackEncodedStringToUnsignedChars(DFA47_minS);
    static final char[] DFA47_max = DFA.unpackEncodedStringToUnsignedChars(DFA47_maxS);
    static final short[] DFA47_accept = DFA.unpackEncodedString(DFA47_acceptS);
    static final short[] DFA47_special = DFA.unpackEncodedString(DFA47_specialS);
    static final short[][] DFA47_transition;

    static {
        int numStates = DFA47_transitionS.length;
        DFA47_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA47_transition[i] = DFA.unpackEncodedString(DFA47_transitionS[i]);
        }
    }

    class DFA47 extends DFA {

        public DFA47(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 47;
            this.eot = DFA47_eot;
            this.eof = DFA47_eof;
            this.min = DFA47_min;
            this.max = DFA47_max;
            this.accept = DFA47_accept;
            this.special = DFA47_special;
            this.transition = DFA47_transition;
        }
        public String getDescription() {
            return "432:4: ( joinedTable | singleTable | nestedTableExpression | tableFunction )";
        }
    }
    static final String DFA52_eotS =
        "\14\uffff";
    static final String DFA52_eofS =
        "\14\uffff";
    static final String DFA52_minS =
        "\1\45\1\uffff\2\45\10\uffff";
    static final String DFA52_maxS =
        "\1\52\1\uffff\2\52\10\uffff";
    static final String DFA52_acceptS =
        "\1\uffff\1\1\2\uffff\1\3\1\4\1\uffff\1\2\4\uffff";
    static final String DFA52_specialS =
        "\14\uffff}>";
    static final String[] DFA52_transitionS = {
            "\1\5\1\1\1\2\1\3\1\uffff\1\4",
            "",
            "\1\7\3\uffff\1\7\1\4",
            "\1\7\3\uffff\1\7\1\4",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA52_eot = DFA.unpackEncodedString(DFA52_eotS);
    static final short[] DFA52_eof = DFA.unpackEncodedString(DFA52_eofS);
    static final char[] DFA52_min = DFA.unpackEncodedStringToUnsignedChars(DFA52_minS);
    static final char[] DFA52_max = DFA.unpackEncodedStringToUnsignedChars(DFA52_maxS);
    static final short[] DFA52_accept = DFA.unpackEncodedString(DFA52_acceptS);
    static final short[] DFA52_special = DFA.unpackEncodedString(DFA52_specialS);
    static final short[][] DFA52_transition;

    static {
        int numStates = DFA52_transitionS.length;
        DFA52_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA52_transition[i] = DFA.unpackEncodedString(DFA52_transitionS[i]);
        }
    }

    class DFA52 extends DFA {

        public DFA52(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 52;
            this.eot = DFA52_eot;
            this.eof = DFA52_eof;
            this.min = DFA52_min;
            this.max = DFA52_max;
            this.accept = DFA52_accept;
            this.special = DFA52_special;
            this.transition = DFA52_transition;
        }
        public String getDescription() {
            return "445:5: (inner= INNER | (dir= LEFT | dir= RIGHT ) ( OUTER )? | (dir= LEFT | dir= RIGHT )? exception= EXCEPTION )?";
        }
    }
    static final String DFA56_eotS =
        "\33\uffff";
    static final String DFA56_eofS =
        "\1\2\32\uffff";
    static final String DFA56_minS =
        "\1\5\1\35\31\uffff";
    static final String DFA56_maxS =
        "\2\170\31\uffff";
    static final String DFA56_acceptS =
        "\2\uffff\1\2\25\uffff\1\1\2\uffff";
    static final String DFA56_specialS =
        "\33\uffff}>";
    static final String[] DFA56_transitionS = {
            "\1\2\3\uffff\1\2\5\uffff\1\2\3\uffff\1\2\1\uffff\1\2\10\uffff"+
            "\1\2\1\uffff\11\2\1\uffff\2\2\66\uffff\1\2\2\uffff\1\2\1\1\1"+
            "\2\20\uffff\1\2",
            "\1\2\110\uffff\1\2\21\uffff\1\30",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA56_eot = DFA.unpackEncodedString(DFA56_eotS);
    static final short[] DFA56_eof = DFA.unpackEncodedString(DFA56_eofS);
    static final char[] DFA56_min = DFA.unpackEncodedStringToUnsignedChars(DFA56_minS);
    static final char[] DFA56_max = DFA.unpackEncodedStringToUnsignedChars(DFA56_maxS);
    static final short[] DFA56_accept = DFA.unpackEncodedString(DFA56_acceptS);
    static final short[] DFA56_special = DFA.unpackEncodedString(DFA56_specialS);
    static final short[][] DFA56_transition;

    static {
        int numStates = DFA56_transitionS.length;
        DFA56_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA56_transition[i] = DFA.unpackEncodedString(DFA56_transitionS[i]);
        }
    }

    class DFA56 extends DFA {

        public DFA56(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 56;
            this.eot = DFA56_eot;
            this.eof = DFA56_eof;
            this.min = DFA56_min;
            this.max = DFA56_max;
            this.accept = DFA56_accept;
            this.special = DFA56_special;
            this.transition = DFA56_transition;
        }
        public String getDescription() {
            return "473:3: ( LPAREN columnName ( COMMA columnName )* RPAREN )?";
        }
    }
    static final String DFA58_eotS =
        "\33\uffff";
    static final String DFA58_eofS =
        "\1\1\32\uffff";
    static final String DFA58_minS =
        "\1\5\32\uffff";
    static final String DFA58_maxS =
        "\1\170\32\uffff";
    static final String DFA58_acceptS =
        "\1\uffff\1\2\27\uffff\1\1\1\uffff";
    static final String DFA58_specialS =
        "\33\uffff}>";
    static final String[] DFA58_transitionS = {
            "\1\1\3\uffff\1\1\5\uffff\1\1\3\uffff\1\1\1\uffff\1\1\10\uffff"+
            "\1\1\1\uffff\11\1\1\uffff\2\1\1\uffff\2\31\14\uffff\1\1\46\uffff"+
            "\1\1\2\uffff\3\1\20\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA58_eot = DFA.unpackEncodedString(DFA58_eotS);
    static final short[] DFA58_eof = DFA.unpackEncodedString(DFA58_eofS);
    static final char[] DFA58_min = DFA.unpackEncodedStringToUnsignedChars(DFA58_minS);
    static final char[] DFA58_max = DFA.unpackEncodedStringToUnsignedChars(DFA58_maxS);
    static final short[] DFA58_accept = DFA.unpackEncodedString(DFA58_acceptS);
    static final short[] DFA58_special = DFA.unpackEncodedString(DFA58_specialS);
    static final short[][] DFA58_transition;

    static {
        int numStates = DFA58_transitionS.length;
        DFA58_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA58_transition[i] = DFA.unpackEncodedString(DFA58_transitionS[i]);
        }
    }

    class DFA58 extends DFA {

        public DFA58(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 58;
            this.eot = DFA58_eot;
            this.eof = DFA58_eof;
            this.min = DFA58_min;
            this.max = DFA58_max;
            this.accept = DFA58_accept;
            this.special = DFA58_special;
            this.transition = DFA58_transition;
        }
        public String getDescription() {
            return "()* loopback of 483:23: ( (op= AND | op= OR ) subSearchCondition )*";
        }
    }
    static final String DFA59_eotS =
        "\21\uffff";
    static final String DFA59_eofS =
        "\21\uffff";
    static final String DFA59_minS =
        "\1\54\20\uffff";
    static final String DFA59_maxS =
        "\1\u0080\20\uffff";
    static final String DFA59_acceptS =
        "\1\uffff\1\1\1\2\16\uffff";
    static final String DFA59_specialS =
        "\21\uffff}>";
    static final String[] DFA59_transitionS = {
            "\1\1\5\uffff\1\2\6\uffff\1\2\4\uffff\1\2\47\uffff\1\2\7\uffff"+
            "\2\2\3\uffff\4\2\1\uffff\1\2\3\uffff\5\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA59_eot = DFA.unpackEncodedString(DFA59_eotS);
    static final short[] DFA59_eof = DFA.unpackEncodedString(DFA59_eofS);
    static final char[] DFA59_min = DFA.unpackEncodedStringToUnsignedChars(DFA59_minS);
    static final char[] DFA59_max = DFA.unpackEncodedStringToUnsignedChars(DFA59_maxS);
    static final short[] DFA59_accept = DFA.unpackEncodedString(DFA59_acceptS);
    static final short[] DFA59_special = DFA.unpackEncodedString(DFA59_specialS);
    static final short[][] DFA59_transition;

    static {
        int numStates = DFA59_transitionS.length;
        DFA59_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA59_transition[i] = DFA.unpackEncodedString(DFA59_transitionS[i]);
        }
    }

    class DFA59 extends DFA {

        public DFA59(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 59;
            this.eot = DFA59_eot;
            this.eof = DFA59_eof;
            this.min = DFA59_min;
            this.max = DFA59_max;
            this.accept = DFA59_accept;
            this.special = DFA59_special;
            this.transition = DFA59_transition;
        }
        public String getDescription() {
            return "488:7: (not= NOT )?";
        }
    }
    static final String DFA60_eotS =
        "\41\uffff";
    static final String DFA60_eofS =
        "\41\uffff";
    static final String DFA60_minS =
        "\1\62\1\35\17\uffff\16\0\2\uffff";
    static final String DFA60_maxS =
        "\2\u0080\17\uffff\16\0\2\uffff";
    static final String DFA60_acceptS =
        "\2\uffff\1\2\34\uffff\2\1";
    static final String DFA60_specialS =
        "\1\uffff\1\0\17\uffff\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\12"+
        "\1\13\1\14\1\15\1\16\2\uffff}>";
    static final String[] DFA60_transitionS = {
            "\1\2\6\uffff\1\2\4\uffff\1\2\47\uffff\1\1\7\uffff\2\2\3\uffff"+
            "\4\2\1\uffff\1\2\3\uffff\5\2",
            "\1\2\16\uffff\1\37\5\uffff\1\40\6\uffff\1\36\4\uffff\1\35"+
            "\47\uffff\1\23\7\uffff\2\21\3\uffff\1\24\1\25\1\26\1\27\1\uffff"+
            "\1\22\3\uffff\1\30\1\31\1\32\1\33\1\34",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "\1\uffff",
            "",
            ""
    };

    static final short[] DFA60_eot = DFA.unpackEncodedString(DFA60_eotS);
    static final short[] DFA60_eof = DFA.unpackEncodedString(DFA60_eofS);
    static final char[] DFA60_min = DFA.unpackEncodedStringToUnsignedChars(DFA60_minS);
    static final char[] DFA60_max = DFA.unpackEncodedStringToUnsignedChars(DFA60_maxS);
    static final short[] DFA60_accept = DFA.unpackEncodedString(DFA60_acceptS);
    static final short[] DFA60_special = DFA.unpackEncodedString(DFA60_specialS);
    static final short[][] DFA60_transition;

    static {
        int numStates = DFA60_transitionS.length;
        DFA60_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA60_transition[i] = DFA.unpackEncodedString(DFA60_transitionS[i]);
        }
    }

    class DFA60 extends DFA {

        public DFA60(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 60;
            this.eot = DFA60_eot;
            this.eof = DFA60_eof;
            this.min = DFA60_min;
            this.max = DFA60_max;
            this.accept = DFA60_accept;
            this.special = DFA60_special;
            this.transition = DFA60_transition;
        }
        public String getDescription() {
            return "488:13: ( ( LPAREN searchCondition RPAREN )=> LPAREN searchCondition RPAREN | predicate )";
        }
        public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
            TokenStream input = (TokenStream)_input;
        	int _s = s;
            switch ( s ) {
                    case 0 : 
                        int LA60_1 = input.LA(1);

                         
                        int index60_1 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (LA60_1==SELECT) ) {s = 2;}

                        else if ( ((LA60_1>=PLUS && LA60_1<=MINUS)) ) {s = 17;}

                        else if ( (LA60_1==IDENTIFIER) ) {s = 18;}

                        else if ( (LA60_1==LPAREN) ) {s = 19;}

                        else if ( (LA60_1==INTEGER) ) {s = 20;}

                        else if ( (LA60_1==DECIMAL) ) {s = 21;}

                        else if ( (LA60_1==FLOAT_POINT) ) {s = 22;}

                        else if ( (LA60_1==CHARACTER_STRING) ) {s = 23;}

                        else if ( (LA60_1==124) ) {s = 24;}

                        else if ( (LA60_1==125) ) {s = 25;}

                        else if ( (LA60_1==126) ) {s = 26;}

                        else if ( (LA60_1==127) ) {s = 27;}

                        else if ( (LA60_1==128) ) {s = 28;}

                        else if ( (LA60_1==CAST) ) {s = 29;}

                        else if ( (LA60_1==CASE) ) {s = 30;}

                        else if ( (LA60_1==NOT) && (synpred1_QTemplate())) {s = 31;}

                        else if ( (LA60_1==EXISTS) && (synpred1_QTemplate())) {s = 32;}

                         
                        input.seek(index60_1);
                        if ( s>=0 ) return s;
                        break;
                    case 1 : 
                        int LA60_17 = input.LA(1);

                         
                        int index60_17 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_17);
                        if ( s>=0 ) return s;
                        break;
                    case 2 : 
                        int LA60_18 = input.LA(1);

                         
                        int index60_18 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_18);
                        if ( s>=0 ) return s;
                        break;
                    case 3 : 
                        int LA60_19 = input.LA(1);

                         
                        int index60_19 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_19);
                        if ( s>=0 ) return s;
                        break;
                    case 4 : 
                        int LA60_20 = input.LA(1);

                         
                        int index60_20 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_20);
                        if ( s>=0 ) return s;
                        break;
                    case 5 : 
                        int LA60_21 = input.LA(1);

                         
                        int index60_21 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_21);
                        if ( s>=0 ) return s;
                        break;
                    case 6 : 
                        int LA60_22 = input.LA(1);

                         
                        int index60_22 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_22);
                        if ( s>=0 ) return s;
                        break;
                    case 7 : 
                        int LA60_23 = input.LA(1);

                         
                        int index60_23 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_23);
                        if ( s>=0 ) return s;
                        break;
                    case 8 : 
                        int LA60_24 = input.LA(1);

                         
                        int index60_24 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_24);
                        if ( s>=0 ) return s;
                        break;
                    case 9 : 
                        int LA60_25 = input.LA(1);

                         
                        int index60_25 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_25);
                        if ( s>=0 ) return s;
                        break;
                    case 10 : 
                        int LA60_26 = input.LA(1);

                         
                        int index60_26 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_26);
                        if ( s>=0 ) return s;
                        break;
                    case 11 : 
                        int LA60_27 = input.LA(1);

                         
                        int index60_27 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_27);
                        if ( s>=0 ) return s;
                        break;
                    case 12 : 
                        int LA60_28 = input.LA(1);

                         
                        int index60_28 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_28);
                        if ( s>=0 ) return s;
                        break;
                    case 13 : 
                        int LA60_29 = input.LA(1);

                         
                        int index60_29 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_29);
                        if ( s>=0 ) return s;
                        break;
                    case 14 : 
                        int LA60_30 = input.LA(1);

                         
                        int index60_30 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (synpred1_QTemplate()) ) {s = 32;}

                        else if ( (true) ) {s = 2;}

                         
                        input.seek(index60_30);
                        if ( s>=0 ) return s;
                        break;
            }
            if (state.backtracking>0) {state.failed=true; return -1;}
            NoViableAltException nvae =
                new NoViableAltException(getDescription(), 60, _s, input);
            error(nvae);
            throw nvae;
        }
    }
    static final String DFA70_eotS =
        "\20\uffff";
    static final String DFA70_eofS =
        "\20\uffff";
    static final String DFA70_minS =
        "\1\62\17\uffff";
    static final String DFA70_maxS =
        "\1\u0080\17\uffff";
    static final String DFA70_acceptS =
        "\1\uffff\1\1\1\2\15\uffff";
    static final String DFA70_specialS =
        "\20\uffff}>";
    static final String[] DFA70_transitionS = {
            "\1\1\6\uffff\1\2\4\uffff\1\2\47\uffff\1\2\7\uffff\2\2\3\uffff"+
            "\4\2\1\uffff\1\2\3\uffff\5\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA70_eot = DFA.unpackEncodedString(DFA70_eotS);
    static final short[] DFA70_eof = DFA.unpackEncodedString(DFA70_eofS);
    static final char[] DFA70_min = DFA.unpackEncodedStringToUnsignedChars(DFA70_minS);
    static final char[] DFA70_max = DFA.unpackEncodedStringToUnsignedChars(DFA70_maxS);
    static final short[] DFA70_accept = DFA.unpackEncodedString(DFA70_acceptS);
    static final short[] DFA70_special = DFA.unpackEncodedString(DFA70_specialS);
    static final short[][] DFA70_transition;

    static {
        int numStates = DFA70_transitionS.length;
        DFA70_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA70_transition[i] = DFA.unpackEncodedString(DFA70_transitionS[i]);
        }
    }

    class DFA70 extends DFA {

        public DFA70(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 70;
            this.eot = DFA70_eot;
            this.eof = DFA70_eof;
            this.min = DFA70_min;
            this.max = DFA70_max;
            this.accept = DFA70_accept;
            this.special = DFA70_special;
            this.transition = DFA70_transition;
        }
        public String getDescription() {
            return "494:1: predicate : ( EXISTS LPAREN subselect RPAREN -> ^( ExistsNode subselect ) | exp= expression (comp= compareOperator (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) ) | ( NOT )? ( LIKE exp1= expression ( ESCAPE expression )? -> ^( LIKE $exp $exp1) | BETWEEN exp1= expression AND exp2= expression -> ^( BETWEEN $exp $exp1 $exp2) | IN LPAREN ( subselect | i+= expression ( COMMA i+= expression )* ) RPAREN -> {$i == null}? ^( IN $exp subselect ) -> ^( IN $exp ^( ArrayNode ( $i)* ) ) ) | IS ( NOT )? NULL -> ^( NotNullNode $exp) ) );";
        }
    }
    static final String DFA62_eotS =
        "\22\uffff";
    static final String DFA62_eofS =
        "\22\uffff";
    static final String DFA62_minS =
        "\1\24\21\uffff";
    static final String DFA62_maxS =
        "\1\u0080\21\uffff";
    static final String DFA62_acceptS =
        "\1\uffff\1\1\15\uffff\1\2\2\uffff";
    static final String DFA62_specialS =
        "\22\uffff}>";
    static final String[] DFA62_transitionS = {
            "\1\17\32\uffff\2\17\10\uffff\1\1\4\uffff\1\1\47\uffff\1\1\7"+
            "\uffff\2\1\3\uffff\4\1\1\uffff\1\1\3\uffff\5\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA62_eot = DFA.unpackEncodedString(DFA62_eotS);
    static final short[] DFA62_eof = DFA.unpackEncodedString(DFA62_eofS);
    static final char[] DFA62_min = DFA.unpackEncodedStringToUnsignedChars(DFA62_minS);
    static final char[] DFA62_max = DFA.unpackEncodedStringToUnsignedChars(DFA62_maxS);
    static final short[] DFA62_accept = DFA.unpackEncodedString(DFA62_acceptS);
    static final short[] DFA62_special = DFA.unpackEncodedString(DFA62_specialS);
    static final short[][] DFA62_transition;

    static {
        int numStates = DFA62_transitionS.length;
        DFA62_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA62_transition[i] = DFA.unpackEncodedString(DFA62_transitionS[i]);
        }
    }

    class DFA62 extends DFA {

        public DFA62(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 62;
            this.eot = DFA62_eot;
            this.eof = DFA62_eof;
            this.min = DFA62_min;
            this.max = DFA62_max;
            this.accept = DFA62_accept;
            this.special = DFA62_special;
            this.transition = DFA62_transition;
        }
        public String getDescription() {
            return "503:26: (exp1= expression -> ^( CompareNode $comp $exp $exp1) | (num= SOME | num= ALL | num= ANY ) LPAREN subselect RPAREN -> ^( CompareNode $comp $exp $num subselect ) )";
        }
    }
    static final String DFA64_eotS =
        "\34\uffff";
    static final String DFA64_eofS =
        "\1\2\33\uffff";
    static final String DFA64_minS =
        "\1\5\33\uffff";
    static final String DFA64_maxS =
        "\1\170\33\uffff";
    static final String DFA64_acceptS =
        "\1\uffff\1\1\1\2\31\uffff";
    static final String DFA64_specialS =
        "\34\uffff}>";
    static final String[] DFA64_transitionS = {
            "\1\2\3\uffff\1\2\5\uffff\1\2\3\uffff\1\2\1\uffff\1\2\10\uffff"+
            "\1\2\1\uffff\11\2\1\uffff\2\2\1\uffff\2\2\6\uffff\1\1\5\uffff"+
            "\1\2\46\uffff\1\2\2\uffff\3\2\20\uffff\1\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA64_eot = DFA.unpackEncodedString(DFA64_eotS);
    static final short[] DFA64_eof = DFA.unpackEncodedString(DFA64_eofS);
    static final char[] DFA64_min = DFA.unpackEncodedStringToUnsignedChars(DFA64_minS);
    static final char[] DFA64_max = DFA.unpackEncodedStringToUnsignedChars(DFA64_maxS);
    static final short[] DFA64_accept = DFA.unpackEncodedString(DFA64_acceptS);
    static final short[] DFA64_special = DFA.unpackEncodedString(DFA64_specialS);
    static final short[][] DFA64_transition;

    static {
        int numStates = DFA64_transitionS.length;
        DFA64_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA64_transition[i] = DFA.unpackEncodedString(DFA64_transitionS[i]);
        }
    }

    class DFA64 extends DFA {

        public DFA64(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 64;
            this.eot = DFA64_eot;
            this.eof = DFA64_eof;
            this.min = DFA64_min;
            this.max = DFA64_max;
            this.accept = DFA64_accept;
            this.special = DFA64_special;
            this.transition = DFA64_transition;
        }
        public String getDescription() {
            return "510:26: ( ESCAPE expression )?";
        }
    }
    static final String DFA66_eotS =
        "\20\uffff";
    static final String DFA66_eofS =
        "\20\uffff";
    static final String DFA66_minS =
        "\1\35\17\uffff";
    static final String DFA66_maxS =
        "\1\u0080\17\uffff";
    static final String DFA66_acceptS =
        "\1\uffff\1\1\1\2\15\uffff";
    static final String DFA66_specialS =
        "\20\uffff}>";
    static final String[] DFA66_transitionS = {
            "\1\1\33\uffff\1\2\4\uffff\1\2\47\uffff\1\2\7\uffff\2\2\3\uffff"+
            "\4\2\1\uffff\1\2\3\uffff\5\2",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA66_eot = DFA.unpackEncodedString(DFA66_eotS);
    static final short[] DFA66_eof = DFA.unpackEncodedString(DFA66_eofS);
    static final char[] DFA66_min = DFA.unpackEncodedStringToUnsignedChars(DFA66_minS);
    static final char[] DFA66_max = DFA.unpackEncodedStringToUnsignedChars(DFA66_maxS);
    static final short[] DFA66_accept = DFA.unpackEncodedString(DFA66_acceptS);
    static final short[] DFA66_special = DFA.unpackEncodedString(DFA66_specialS);
    static final short[][] DFA66_transition;

    static {
        int numStates = DFA66_transitionS.length;
        DFA66_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA66_transition[i] = DFA.unpackEncodedString(DFA66_transitionS[i]);
        }
    }

    class DFA66 extends DFA {

        public DFA66(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 66;
            this.eot = DFA66_eot;
            this.eof = DFA66_eof;
            this.min = DFA66_min;
            this.max = DFA66_max;
            this.accept = DFA66_accept;
            this.special = DFA66_special;
            this.transition = DFA66_transition;
        }
        public String getDescription() {
            return "514:18: ( subselect | i+= expression ( COMMA i+= expression )* )";
        }
    }
    static final String DFA71_eotS =
        "\14\uffff";
    static final String DFA71_eofS =
        "\1\1\13\uffff";
    static final String DFA71_minS =
        "\1\5\13\uffff";
    static final String DFA71_maxS =
        "\1\147\13\uffff";
    static final String DFA71_acceptS =
        "\1\uffff\1\2\11\uffff\1\1";
    static final String DFA71_specialS =
        "\14\uffff}>";
    static final String[] DFA71_transitionS = {
            "\1\1\3\uffff\1\1\5\uffff\1\1\3\uffff\1\1\1\uffff\1\1\10\uffff"+
            "\1\1\4\uffff\1\1\76\uffff\1\13\2\uffff\1\1\1\uffff\1\1",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA71_eot = DFA.unpackEncodedString(DFA71_eotS);
    static final short[] DFA71_eof = DFA.unpackEncodedString(DFA71_eofS);
    static final char[] DFA71_min = DFA.unpackEncodedStringToUnsignedChars(DFA71_minS);
    static final char[] DFA71_max = DFA.unpackEncodedStringToUnsignedChars(DFA71_maxS);
    static final short[] DFA71_accept = DFA.unpackEncodedString(DFA71_acceptS);
    static final short[] DFA71_special = DFA.unpackEncodedString(DFA71_specialS);
    static final short[][] DFA71_transition;

    static {
        int numStates = DFA71_transitionS.length;
        DFA71_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA71_transition[i] = DFA.unpackEncodedString(DFA71_transitionS[i]);
        }
    }

    class DFA71 extends DFA {

        public DFA71(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 71;
            this.eot = DFA71_eot;
            this.eof = DFA71_eof;
            this.min = DFA71_min;
            this.max = DFA71_max;
            this.accept = DFA71_accept;
            this.special = DFA71_special;
            this.transition = DFA71_transition;
        }
        public String getDescription() {
            return "()* loopback of 531:15: ( COMMA expression )*";
        }
    }
    static final String DFA73_eotS =
        "\13\uffff";
    static final String DFA73_eofS =
        "\1\3\12\uffff";
    static final String DFA73_minS =
        "\1\7\12\uffff";
    static final String DFA73_maxS =
        "\1\147\12\uffff";
    static final String DFA73_acceptS =
        "\1\uffff\1\1\1\2\1\3\7\uffff";
    static final String DFA73_specialS =
        "\13\uffff}>";
    static final String[] DFA73_transitionS = {
            "\1\1\1\2\1\3\5\uffff\1\3\3\uffff\1\3\1\uffff\1\3\114\uffff"+
            "\1\3\2\uffff\1\3\1\uffff\1\3",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""
    };

    static final short[] DFA73_eot = DFA.unpackEncodedString(DFA73_eotS);
    static final short[] DFA73_eof = DFA.unpackEncodedString(DFA73_eofS);
    static final char[] DFA73_min = DFA.unpackEncodedStringToUnsignedChars(DFA73_minS);
    static final char[] DFA73_max = DFA.unpackEncodedStringToUnsignedChars(DFA73_maxS);
    static final short[] DFA73_accept = DFA.unpackEncodedString(DFA73_acceptS);
    static final short[] DFA73_special = DFA.unpackEncodedString(DFA73_specialS);
    static final short[][] DFA73_transition;

    static {
        int numStates = DFA73_transitionS.length;
        DFA73_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA73_transition[i] = DFA.unpackEncodedString(DFA73_transitionS[i]);
        }
    }

    class DFA73 extends DFA {

        public DFA73(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 73;
            this.eot = DFA73_eot;
            this.eof = DFA73_eof;
            this.min = DFA73_min;
            this.max = DFA73_max;
            this.accept = DFA73_accept;
            this.special = DFA73_special;
            this.transition = DFA73_transition;
        }
        public String getDescription() {
            return "546:12: (order= ASC | order= DESC )?";
        }
    }
 

    public static final BitSet FOLLOW_selectStatement_in_start1118 = new BitSet(new long[]{0x0000000000000000L,0x0000002000000000L});
    public static final BitSet FOLLOW_SEMICOLON_in_start1121 = new BitSet(new long[]{0x0000000020200000L,0x0000004000000000L});
    public static final BitSet FOLLOW_selectStatement_in_start1125 = new BitSet(new long[]{0x0000000000000000L,0x0000002000000000L});
    public static final BitSet FOLLOW_SEMICOLON_in_start1130 = new BitSet(new long[]{0x0000000000000000L});
    public static final BitSet FOLLOW_EOF_in_start1136 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_WITH_in_selectStatement1167 = new BitSet(new long[]{0x0000000000000000L,0x0100001000000000L});
    public static final BitSet FOLLOW_commonTableExpression_in_selectStatement1169 = new BitSet(new long[]{0x0000000020200000L,0x0000004400000000L});
    public static final BitSet FOLLOW_COMMA_in_selectStatement1172 = new BitSet(new long[]{0x0000000000000000L,0x0100001000000000L});
    public static final BitSet FOLLOW_commonTableExpression_in_selectStatement1174 = new BitSet(new long[]{0x0000000020200000L,0x0000004400000000L});
    public static final BitSet FOLLOW_fullselect_in_selectStatement1187 = new BitSet(new long[]{0x0000000000288222L});
    public static final BitSet FOLLOW_orderByClause_in_selectStatement1195 = new BitSet(new long[]{0x0000000000288202L});
    public static final BitSet FOLLOW_fetchFirstClause_in_selectStatement1205 = new BitSet(new long[]{0x0000000000288002L});
    public static final BitSet FOLLOW_updateClause_in_selectStatement1215 = new BitSet(new long[]{0x0000000000288002L});
    public static final BitSet FOLLOW_readOnlyClause_in_selectStatement1219 = new BitSet(new long[]{0x0000000000288002L});
    public static final BitSet FOLLOW_optimizeClause_in_selectStatement1223 = new BitSet(new long[]{0x0000000000288002L});
    public static final BitSet FOLLOW_isolationClause_in_selectStatement1227 = new BitSet(new long[]{0x0000000000288002L});
    public static final BitSet FOLLOW_STAR_in_commonTableExpression1318 = new BitSet(new long[]{0x0000000000000010L,0x0000004000000000L});
    public static final BitSet FOLLOW_identifier_in_commonTableExpression1324 = new BitSet(new long[]{0x0000000000000010L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_commonTableExpression1336 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_commonTableExpression1338 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_COMMA_in_commonTableExpression1341 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_commonTableExpression1343 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_RPAREN_in_commonTableExpression1347 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_AS_in_commonTableExpression1356 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_commonTableExpression1358 = new BitSet(new long[]{0x0000000020200000L,0x0000004000000000L});
    public static final BitSet FOLLOW_fullselect_in_commonTableExpression1367 = new BitSet(new long[]{0x0000000000000220L,0x0000008000000000L});
    public static final BitSet FOLLOW_orderByClause_in_commonTableExpression1377 = new BitSet(new long[]{0x0000000000000200L,0x0000008000000000L});
    public static final BitSet FOLLOW_fetchFirstClause_in_commonTableExpression1389 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_commonTableExpression1399 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_identifier1484 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_columnName1496 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_subQueryExpression_in_fullselect1509 = new BitSet(new long[]{0x0000000040000002L});
    public static final BitSet FOLLOW_UNION_in_fullselect1515 = new BitSet(new long[]{0x00000000A0300000L,0x0000004000000000L});
    public static final BitSet FOLLOW_DISTINCT_in_fullselect1518 = new BitSet(new long[]{0x0000000020200000L,0x0000004000000000L});
    public static final BitSet FOLLOW_ALL_in_fullselect1522 = new BitSet(new long[]{0x0000000020200000L,0x0000004000000000L});
    public static final BitSet FOLLOW_subQueryExpression_in_fullselect1526 = new BitSet(new long[]{0x0000000040000002L});
    public static final BitSet FOLLOW_subselect_in_subQueryExpression1551 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LPAREN_in_subQueryExpression1566 = new BitSet(new long[]{0x0000000020200000L,0x0000004000000000L});
    public static final BitSet FOLLOW_fullselect_in_subQueryExpression1568 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_subQueryExpression1570 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_selectClause_in_subselect1588 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_fromClause_in_subselect1593 = new BitSet(new long[]{0x0000000E00000002L});
    public static final BitSet FOLLOW_whereClause_in_subselect1598 = new BitSet(new long[]{0x0000000C00000002L});
    public static final BitSet FOLLOW_groupByClause_in_subselect1604 = new BitSet(new long[]{0x0000000800000002L});
    public static final BitSet FOLLOW_havingClause_in_subselect1610 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SELECT_in_selectClause1680 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_ALL_in_selectClause1684 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_DISTINCT_in_selectClause1688 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_selectItem_in_selectClause1696 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_COMMA_in_selectClause1699 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_selectItem_in_selectClause1701 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_STAR_in_selectItem1735 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_TABLE_COLUMNS_in_selectItem1752 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_selectItem1770 = new BitSet(new long[]{0x0000000000000012L,0x0100000000000000L});
    public static final BitSet FOLLOW_AS_in_selectItem1773 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_selectItem1776 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_subExpression_in_expression1808 = new BitSet(new long[]{0x0100000000000002L,0x0003C01800000000L});
    public static final BitSet FOLLOW_binaryOperator_in_expression1812 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_subExpression_in_expression1814 = new BitSet(new long[]{0x0100000000000002L,0x0003C01800000000L});
    public static final BitSet FOLLOW_unaryOperator_in_subExpression1830 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_function_in_subExpression1840 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LPAREN_in_subExpression1848 = new BitSet(new long[]{0x42000000A0100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_scalarSubSelect_in_subExpression1851 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_expression_in_subExpression1855 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_subExpression1858 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_constant_in_subExpression1866 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_columnName_in_subExpression1874 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_specialRegister_in_subExpression1883 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_castSpecification_in_subExpression1892 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_caseExpression_in_subExpression1900 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_function1986 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_function1991 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C0D000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_STAR_in_function1999 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_ALL_in_function2004 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_DISTINCT_in_function2006 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_function2011 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_COMMA_in_function2014 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_function2016 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_RPAREN_in_function2027 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_constant2062 = new BitSet(new long[]{0x0000000000000000L,0x0008000000000000L});
    public static final BitSet FOLLOW_INTEGER_in_constant2068 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DECIMAL_in_constant2074 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FLOAT_POINT_in_constant2080 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CHARACTER_STRING_in_constant2086 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_124_in_constant2092 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_125_in_constant2098 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_126_in_constant2104 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_127_in_constant2110 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_128_in_specialRegister2122 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_subselect_in_scalarSubSelect2135 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_function_in_labeledDuration2151 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_LPAREN_in_labeledDuration2159 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_labeledDuration2161 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_labeledDuration2163 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_constant_in_labeledDuration2170 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_labeledDuration2177 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_IDENTIFIER_in_labeledDuration2189 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CAST_in_castSpecification2201 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_castSpecification2203 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_castSpecification2211 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_AS_in_castSpecification2213 = new BitSet(new long[]{0x0000000000000000L,0x0100001000000000L});
    public static final BitSet FOLLOW_identifier_in_castSpecification2221 = new BitSet(new long[]{0x0000000000000000L,0x000000C000000000L});
    public static final BitSet FOLLOW_LPAREN_in_castSpecification2224 = new BitSet(new long[]{0x0000000000000000L,0x0008000000000000L});
    public static final BitSet FOLLOW_INTEGER_in_castSpecification2228 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_COMMA_in_castSpecification2231 = new BitSet(new long[]{0x0000000000000000L,0x0008000000000000L});
    public static final BitSet FOLLOW_INTEGER_in_castSpecification2235 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_castSpecification2239 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_castSpecification2246 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CASE_in_caseExpression2276 = new BitSet(new long[]{0x4600000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_caseExpression2286 = new BitSet(new long[]{0x0400000000000000L});
    public static final BitSet FOLLOW_WHEN_in_caseExpression2289 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_caseExpression2293 = new BitSet(new long[]{0x0800000000000000L});
    public static final BitSet FOLLOW_THEN_in_caseExpression2295 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_caseExpression2299 = new BitSet(new long[]{0x3400000000000000L});
    public static final BitSet FOLLOW_WHEN_in_caseExpression2309 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_searchCondition_in_caseExpression2313 = new BitSet(new long[]{0x0800000000000000L});
    public static final BitSet FOLLOW_THEN_in_caseExpression2315 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_caseExpression2319 = new BitSet(new long[]{0x3400000000000000L});
    public static final BitSet FOLLOW_ELSE_in_caseExpression2334 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_caseExpression2338 = new BitSet(new long[]{0x2000000000000000L});
    public static final BitSet FOLLOW_END_in_caseExpression2345 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_compareOperator2400 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_unaryOperator0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_arithmeticOperator_in_binaryOperator2441 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_bitwiseOperator_in_binaryOperator2445 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_arithmeticOperator0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DOUBLE_BITWISEOR_in_bitwiseOperator2502 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FROM_in_fromClause2513 = new BitSet(new long[]{0x000005F100000000L,0x0100005400000000L});
    public static final BitSet FOLLOW_tableReference_in_fromClause2515 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_COMMA_in_fromClause2518 = new BitSet(new long[]{0x000005F100000000L,0x0100005400000000L});
    public static final BitSet FOLLOW_tableReference_in_fromClause2520 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_identifier_in_singleTable2547 = new BitSet(new long[]{0x0000000000000012L,0x0100001000000000L});
    public static final BitSet FOLLOW_correlationClause_in_singleTable2553 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LPAREN_in_nestedTableExpression2591 = new BitSet(new long[]{0x0000000020200000L,0x0000004000000000L});
    public static final BitSet FOLLOW_fullselect_in_nestedTableExpression2597 = new BitSet(new long[]{0x0000000000000220L,0x0000008000000000L});
    public static final BitSet FOLLOW_orderByClause_in_nestedTableExpression2599 = new BitSet(new long[]{0x0000000000000200L,0x0000008000000000L});
    public static final BitSet FOLLOW_fetchFirstClause_in_nestedTableExpression2602 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_nestedTableExpression2608 = new BitSet(new long[]{0x0000000000000010L,0x0100001000000000L});
    public static final BitSet FOLLOW_correlationClause_in_nestedTableExpression2615 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_TABLE_in_tableFunction2649 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_tableFunction2651 = new BitSet(new long[]{0x0000000000000000L,0x0100001000000000L});
    public static final BitSet FOLLOW_identifier_in_tableFunction2659 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_tableFunction2665 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C0D000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_tableFunction2670 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_COMMA_in_tableFunction2673 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_tableFunction2677 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_RPAREN_in_tableFunction2683 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_tableFunction2688 = new BitSet(new long[]{0x0000000000000010L,0x0100001000000000L});
    public static final BitSet FOLLOW_correlationClause_in_tableFunction2692 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_joinedTable_in_tableReference2741 = new BitSet(new long[]{0x000005F100000000L,0x0100005000000000L});
    public static final BitSet FOLLOW_singleTable_in_tableReference2749 = new BitSet(new long[]{0x000005F100000000L,0x0100005000000000L});
    public static final BitSet FOLLOW_nestedTableExpression_in_tableReference2757 = new BitSet(new long[]{0x000005F100000000L,0x0100005000000000L});
    public static final BitSet FOLLOW_tableFunction_in_tableReference2765 = new BitSet(new long[]{0x000005F100000000L,0x0100005000000000L});
    public static final BitSet FOLLOW_tableReference_in_tableReference2773 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CROSS_in_joinedTable2793 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_JOIN_in_joinedTable2795 = new BitSet(new long[]{0x000005F100000000L,0x0100005000000000L});
    public static final BitSet FOLLOW_tableReference_in_joinedTable2797 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INNER_in_joinedTable2821 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_LEFT_in_joinedTable2831 = new BitSet(new long[]{0x0000022000000000L});
    public static final BitSet FOLLOW_RIGHT_in_joinedTable2835 = new BitSet(new long[]{0x0000022000000000L});
    public static final BitSet FOLLOW_OUTER_in_joinedTable2838 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_LEFT_in_joinedTable2849 = new BitSet(new long[]{0x0000040000000000L});
    public static final BitSet FOLLOW_RIGHT_in_joinedTable2853 = new BitSet(new long[]{0x0000040000000000L});
    public static final BitSet FOLLOW_EXCEPTION_in_joinedTable2859 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_JOIN_in_joinedTable2866 = new BitSet(new long[]{0x00000DF100000000L,0x0100005000000000L});
    public static final BitSet FOLLOW_tableReference_in_joinedTable2868 = new BitSet(new long[]{0x0000080000000000L});
    public static final BitSet FOLLOW_ON_in_joinedTable2870 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_searchCondition_in_joinedTable2872 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_AS_in_correlationClause3066 = new BitSet(new long[]{0x0000000000000000L,0x0100001000000000L});
    public static final BitSet FOLLOW_identifier_in_correlationClause3071 = new BitSet(new long[]{0x0000000000000002L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_correlationClause3078 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_correlationClause3080 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_COMMA_in_correlationClause3083 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_correlationClause3085 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_RPAREN_in_correlationClause3089 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_WHERE_in_whereClause3112 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_searchCondition_in_whereClause3114 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_subSearchCondition_in_searchCondition3136 = new BitSet(new long[]{0x0000600000000002L});
    public static final BitSet FOLLOW_AND_in_searchCondition3142 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_OR_in_searchCondition3146 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_subSearchCondition_in_searchCondition3149 = new BitSet(new long[]{0x0000600000000002L});
    public static final BitSet FOLLOW_NOT_in_subSearchCondition3187 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_LPAREN_in_subSearchCondition3205 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_searchCondition_in_subSearchCondition3207 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_subSearchCondition3209 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_predicate_in_subSearchCondition3216 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_EXISTS_in_predicate3247 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_predicate3249 = new BitSet(new long[]{0x0000000020000000L});
    public static final BitSet FOLLOW_subselect_in_predicate3251 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_predicate3253 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_predicate3278 = new BitSet(new long[]{0x005A100000000000L,0x00003F0000000000L});
    public static final BitSet FOLLOW_compareOperator_in_predicate3288 = new BitSet(new long[]{0x4201800080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_predicate3299 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SOME_in_predicate3331 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_ALL_in_predicate3335 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_ANY_in_predicate3339 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_predicate3342 = new BitSet(new long[]{0x0000000020000000L});
    public static final BitSet FOLLOW_subselect_in_predicate3344 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_predicate3346 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NOT_in_predicate3380 = new BitSet(new long[]{0x001A000000000000L});
    public static final BitSet FOLLOW_LIKE_in_predicate3389 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_predicate3393 = new BitSet(new long[]{0x0020000000000002L});
    public static final BitSet FOLLOW_ESCAPE_in_predicate3396 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_predicate3398 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_BETWEEN_in_predicate3425 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_predicate3429 = new BitSet(new long[]{0x0000200000000000L});
    public static final BitSet FOLLOW_AND_in_predicate3431 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_predicate3435 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IN_in_predicate3464 = new BitSet(new long[]{0x0000000000000000L,0x0000004000000000L});
    public static final BitSet FOLLOW_LPAREN_in_predicate3467 = new BitSet(new long[]{0x42000000A0100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_subselect_in_predicate3476 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_expression_in_predicate3482 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_COMMA_in_predicate3485 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_predicate3489 = new BitSet(new long[]{0x0000000000000000L,0x0000008400000000L});
    public static final BitSet FOLLOW_RPAREN_in_predicate3500 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IS_in_predicate3566 = new BitSet(new long[]{0x0080100000000000L});
    public static final BitSet FOLLOW_NOT_in_predicate3568 = new BitSet(new long[]{0x0080000000000000L});
    public static final BitSet FOLLOW_NULL_in_predicate3571 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_GROUP_in_groupByClause3604 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_BY_in_groupByClause3606 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_groupingExpression_in_groupByClause3608 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_groupingExpression3630 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_COMMA_in_groupingExpression3633 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_expression_in_groupingExpression3635 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_HAVING_in_havingClause3664 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_searchCondition_in_havingClause3666 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ORDER_in_orderByClause3688 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_BY_in_orderByClause3690 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_subOrder_in_orderByClause3692 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_COMMA_in_orderByClause3695 = new BitSet(new long[]{0x4200000080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_subOrder_in_orderByClause3697 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_sortKey_in_subOrder3721 = new BitSet(new long[]{0x0000000000000182L});
    public static final BitSet FOLLOW_ASC_in_subOrder3726 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DESC_in_subOrder3730 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_sortKey3759 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FETCH_in_fetchFirstClause3772 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_FIRST_in_fetchFirstClause3774 = new BitSet(new long[]{0x0000000000000000L,0x0008000000000000L});
    public static final BitSet FOLLOW_INTEGER_in_fetchFirstClause3779 = new BitSet(new long[]{0x0000000000003000L});
    public static final BitSet FOLLOW_ROW_in_fetchFirstClause3784 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_ROWS_in_fetchFirstClause3788 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_ONLY_in_fetchFirstClause3791 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FOR_in_updateClause3814 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_UPDATE_in_updateClause3816 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_OF_in_updateClause3819 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_updateClause3821 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_COMMA_in_updateClause3824 = new BitSet(new long[]{0x0000000000000000L,0x0100000000000000L});
    public static final BitSet FOLLOW_columnName_in_updateClause3826 = new BitSet(new long[]{0x0000000000000002L,0x0000000400000000L});
    public static final BitSet FOLLOW_FOR_in_readOnlyClause3844 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_READ_in_readOnlyClause3846 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_ONLY_in_readOnlyClause3848 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_OPTIMIZE_in_optimizeClause3861 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_FOR_in_optimizeClause3863 = new BitSet(new long[]{0x0000000000100000L,0x0008000000000000L});
    public static final BitSet FOLLOW_set_in_optimizeClause3865 = new BitSet(new long[]{0x0000000000003000L});
    public static final BitSet FOLLOW_set_in_optimizeClause3873 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_WITH_in_isolationClause3892 = new BitSet(new long[]{0x0000000019C00000L});
    public static final BitSet FOLLOW_NC_in_isolationClause3895 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_UR_in_isolationClause3899 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CS_in_isolationClause3903 = new BitSet(new long[]{0x0000000002000002L});
    public static final BitSet FOLLOW_KEEP_in_isolationClause3906 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_LOCKS_in_isolationClause3908 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_RS_in_isolationClause3914 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_RR_in_isolationClause3918 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LPAREN_in_synpred1_QTemplate3196 = new BitSet(new long[]{0x4204100080100000L,0xF1F8C05000000000L,0x0000000000000001L});
    public static final BitSet FOLLOW_searchCondition_in_synpred1_QTemplate3198 = new BitSet(new long[]{0x0000000000000000L,0x0000008000000000L});
    public static final BitSet FOLLOW_RPAREN_in_synpred1_QTemplate3200 = new BitSet(new long[]{0x0000000000000002L});

}